Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Unified Diff: src/inspector/RemoteObjectId.cpp

Issue 2292573002: [inspector] Initial import of v8_inspector. (Closed)
Patch Set: format the code, disable cpplint Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/RemoteObjectId.h ('k') | src/inspector/ScriptBreakpoint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/RemoteObjectId.cpp
diff --git a/src/inspector/RemoteObjectId.cpp b/src/inspector/RemoteObjectId.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..75cd17bf9054b10a671ce20c49235e4871b165b4
--- /dev/null
+++ b/src/inspector/RemoteObjectId.cpp
@@ -0,0 +1,76 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/inspector/RemoteObjectId.h"
+
+#include "src/inspector/StringUtil.h"
+#include "src/inspector/protocol/Protocol.h"
+
+namespace v8_inspector {
+
+RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) {}
+
+std::unique_ptr<protocol::DictionaryValue>
+RemoteObjectIdBase::parseInjectedScriptId(const String16& objectId) {
+ std::unique_ptr<protocol::Value> parsedValue = protocol::parseJSON(objectId);
+ if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject)
+ return nullptr;
+
+ std::unique_ptr<protocol::DictionaryValue> parsedObjectId(
+ protocol::DictionaryValue::cast(parsedValue.release()));
+ bool success =
+ parsedObjectId->getInteger("injectedScriptId", &m_injectedScriptId);
+ if (success) return parsedObjectId;
+ return nullptr;
+}
+
+RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) {}
+
+std::unique_ptr<RemoteObjectId> RemoteObjectId::parse(
+ ErrorString* errorString, const String16& objectId) {
+ std::unique_ptr<RemoteObjectId> result(new RemoteObjectId());
+ std::unique_ptr<protocol::DictionaryValue> parsedObjectId =
+ result->parseInjectedScriptId(objectId);
+ if (!parsedObjectId) {
+ *errorString = "Invalid remote object id";
+ return nullptr;
+ }
+
+ bool success = parsedObjectId->getInteger("id", &result->m_id);
+ if (!success) {
+ *errorString = "Invalid remote object id";
+ return nullptr;
+ }
+ return result;
+}
+
+RemoteCallFrameId::RemoteCallFrameId()
+ : RemoteObjectIdBase(), m_frameOrdinal(0) {}
+
+std::unique_ptr<RemoteCallFrameId> RemoteCallFrameId::parse(
+ ErrorString* errorString, const String16& objectId) {
+ std::unique_ptr<RemoteCallFrameId> result(new RemoteCallFrameId());
+ std::unique_ptr<protocol::DictionaryValue> parsedObjectId =
+ result->parseInjectedScriptId(objectId);
+ if (!parsedObjectId) {
+ *errorString = "Invalid call frame id";
+ return nullptr;
+ }
+
+ bool success = parsedObjectId->getInteger("ordinal", &result->m_frameOrdinal);
+ if (!success) {
+ *errorString = "Invalid call frame id";
+ return nullptr;
+ }
+
+ return result;
+}
+
+String16 RemoteCallFrameId::serialize(int injectedScriptId, int frameOrdinal) {
+ return "{\"ordinal\":" + String16::fromInteger(frameOrdinal) +
+ ",\"injectedScriptId\":" + String16::fromInteger(injectedScriptId) +
+ "}";
+}
+
+} // namespace v8_inspector
« no previous file with comments | « src/inspector/RemoteObjectId.h ('k') | src/inspector/ScriptBreakpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698