LCOV - code coverage report
Current view: top level - src/inspector - remote-object-id.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 26 27 96.3 %
Date: 2019-04-19 Functions: 4 7 57.1 %

          Line data    Source code
       1             : // Copyright 2015 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/inspector/remote-object-id.h"
       6             : 
       7             : #include "src/inspector/protocol/Protocol.h"
       8             : #include "src/inspector/string-util.h"
       9             : 
      10             : namespace v8_inspector {
      11             : 
      12       93896 : RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) {}
      13             : 
      14             : std::unique_ptr<protocol::DictionaryValue>
      15       93896 : RemoteObjectIdBase::parseInjectedScriptId(const String16& objectId) {
      16             :   std::unique_ptr<protocol::Value> parsedValue =
      17       93896 :       protocol::StringUtil::parseJSON(objectId);
      18       93896 :   if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject)
      19             :     return nullptr;
      20             : 
      21             :   std::unique_ptr<protocol::DictionaryValue> parsedObjectId(
      22             :       protocol::DictionaryValue::cast(parsedValue.release()));
      23             :   bool success =
      24      187772 :       parsedObjectId->getInteger("injectedScriptId", &m_injectedScriptId);
      25       93886 :   if (success) return parsedObjectId;
      26             :   return nullptr;
      27             : }
      28             : 
      29       70836 : RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) {}
      30             : 
      31       70836 : Response RemoteObjectId::parse(const String16& objectId,
      32             :                                std::unique_ptr<RemoteObjectId>* result) {
      33       70836 :   std::unique_ptr<RemoteObjectId> remoteObjectId(new RemoteObjectId());
      34             :   std::unique_ptr<protocol::DictionaryValue> parsedObjectId =
      35       70836 :       remoteObjectId->parseInjectedScriptId(objectId);
      36       70836 :   if (!parsedObjectId) return Response::Error("Invalid remote object id");
      37             : 
      38      212508 :   bool success = parsedObjectId->getInteger("id", &remoteObjectId->m_id);
      39       70836 :   if (!success) return Response::Error("Invalid remote object id");
      40             :   *result = std::move(remoteObjectId);
      41       70836 :   return Response::OK();
      42             : }
      43             : 
      44           0 : RemoteCallFrameId::RemoteCallFrameId()
      45       23060 :     : RemoteObjectIdBase(), m_frameOrdinal(0) {}
      46             : 
      47       23060 : Response RemoteCallFrameId::parse(const String16& objectId,
      48             :                                   std::unique_ptr<RemoteCallFrameId>* result) {
      49       23060 :   std::unique_ptr<RemoteCallFrameId> remoteCallFrameId(new RemoteCallFrameId());
      50             :   std::unique_ptr<protocol::DictionaryValue> parsedObjectId =
      51       23060 :       remoteCallFrameId->parseInjectedScriptId(objectId);
      52       23070 :   if (!parsedObjectId) return Response::Error("Invalid call frame id");
      53             : 
      54             :   bool success =
      55       69150 :       parsedObjectId->getInteger("ordinal", &remoteCallFrameId->m_frameOrdinal);
      56       23050 :   if (!success) return Response::Error("Invalid call frame id");
      57             :   *result = std::move(remoteCallFrameId);
      58       23050 :   return Response::OK();
      59             : }
      60             : 
      61      147155 : String16 RemoteCallFrameId::serialize(int injectedScriptId, int frameOrdinal) {
      62      735775 :   return "{\"ordinal\":" + String16::fromInteger(frameOrdinal) +
      63      588620 :          ",\"injectedScriptId\":" + String16::fromInteger(injectedScriptId) +
      64      441465 :          "}";
      65             : }
      66             : 
      67             : }  // namespace v8_inspector

Generated by: LCOV version 1.10