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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.cpp

Issue 2295913003: [DevTools] Switch from platform/v8_inspector to v8/v8-inspector.h. (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium 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 "platform/v8_inspector/RemoteObjectId.h"
6
7 #include "platform/v8_inspector/StringUtil.h"
8 #include "platform/v8_inspector/protocol/Protocol.h"
9
10 namespace v8_inspector {
11
12 RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) { }
13
14 std::unique_ptr<protocol::DictionaryValue> RemoteObjectIdBase::parseInjectedScri ptId(const String16& objectId)
15 {
16 std::unique_ptr<protocol::Value> parsedValue = protocol::parseJSON(objectId) ;
17 if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject)
18 return nullptr;
19
20 std::unique_ptr<protocol::DictionaryValue> parsedObjectId(protocol::Dictiona ryValue::cast(parsedValue.release()));
21 bool success = parsedObjectId->getInteger("injectedScriptId", &m_injectedScr iptId);
22 if (success)
23 return parsedObjectId;
24 return nullptr;
25 }
26
27 RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) { }
28
29 std::unique_ptr<RemoteObjectId> RemoteObjectId::parse(ErrorString* errorString, const String16& objectId)
30 {
31 std::unique_ptr<RemoteObjectId> result(new RemoteObjectId());
32 std::unique_ptr<protocol::DictionaryValue> parsedObjectId = result->parseInj ectedScriptId(objectId);
33 if (!parsedObjectId) {
34 *errorString = "Invalid remote object id";
35 return nullptr;
36 }
37
38 bool success = parsedObjectId->getInteger("id", &result->m_id);
39 if (!success) {
40 *errorString = "Invalid remote object id";
41 return nullptr;
42 }
43 return result;
44 }
45
46 RemoteCallFrameId::RemoteCallFrameId() : RemoteObjectIdBase(), m_frameOrdinal(0) { }
47
48 std::unique_ptr<RemoteCallFrameId> RemoteCallFrameId::parse(ErrorString* errorSt ring, const String16& objectId)
49 {
50 std::unique_ptr<RemoteCallFrameId> result(new RemoteCallFrameId());
51 std::unique_ptr<protocol::DictionaryValue> parsedObjectId = result->parseInj ectedScriptId(objectId);
52 if (!parsedObjectId) {
53 *errorString = "Invalid call frame id";
54 return nullptr;
55 }
56
57 bool success = parsedObjectId->getInteger("ordinal", &result->m_frameOrdinal );
58 if (!success) {
59 *errorString = "Invalid call frame id";
60 return nullptr;
61 }
62
63 return result;
64 }
65
66 String16 RemoteCallFrameId::serialize(int injectedScriptId, int frameOrdinal)
67 {
68 return "{\"ordinal\":" + String16::fromInteger(frameOrdinal) + ",\"injectedS criptId\":" + String16::fromInteger(injectedScriptId) + "}";
69 }
70
71 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698