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

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

Issue 1767883002: DevTools: generate string16-based handlers for v8_inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing 2 Created 4 years, 9 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/RemoteObjectId.h" 5 #include "platform/v8_inspector/RemoteObjectId.h"
6 6
7 #include "platform/inspector_protocol/Parser.h" 7 #include "platform/inspector_protocol/Parser.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 #include "wtf/PassOwnPtr.h" 9 #include "wtf/PassOwnPtr.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) { } 13 RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) { }
14 14
15 PassOwnPtr<protocol::DictionaryValue> RemoteObjectIdBase::parseInjectedScriptId( const String& objectId) 15 PassOwnPtr<protocol::DictionaryValue> RemoteObjectIdBase::parseInjectedScriptId( const String16& objectId)
16 { 16 {
17 OwnPtr<protocol::Value> parsedValue = protocol::parseJSON(objectId); 17 OwnPtr<protocol::Value> parsedValue = protocol::parseJSON(objectId);
18 if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject) 18 if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject)
19 return nullptr; 19 return nullptr;
20 20
21 OwnPtr<protocol::DictionaryValue> parsedObjectId = adoptPtr(protocol::Dictio naryValue::cast(parsedValue.leakPtr())); 21 OwnPtr<protocol::DictionaryValue> parsedObjectId = adoptPtr(protocol::Dictio naryValue::cast(parsedValue.leakPtr()));
22 bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScri ptId); 22 bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScri ptId);
23 if (success) 23 if (success)
24 return parsedObjectId.release(); 24 return parsedObjectId.release();
25 return nullptr; 25 return nullptr;
26 } 26 }
27 27
28 RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) { } 28 RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) { }
29 29
30 PassOwnPtr<RemoteObjectId> RemoteObjectId::parse(const String& objectId) 30 PassOwnPtr<RemoteObjectId> RemoteObjectId::parse(const String16& objectId)
31 { 31 {
32 OwnPtr<RemoteObjectId> result = adoptPtr(new RemoteObjectId()); 32 OwnPtr<RemoteObjectId> result = adoptPtr(new RemoteObjectId());
33 OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri ptId(objectId); 33 OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri ptId(objectId);
34 if (!parsedObjectId) 34 if (!parsedObjectId)
35 return nullptr; 35 return nullptr;
36 36
37 bool success = parsedObjectId->getNumber("id", &result->m_id); 37 bool success = parsedObjectId->getNumber("id", &result->m_id);
38 if (success) 38 if (success)
39 return result.release(); 39 return result.release();
40 return nullptr; 40 return nullptr;
41 } 41 }
42 42
43 RemoteCallFrameId::RemoteCallFrameId() : RemoteObjectIdBase(), m_frameOrdinal(0) { } 43 RemoteCallFrameId::RemoteCallFrameId() : RemoteObjectIdBase(), m_frameOrdinal(0) { }
44 44
45 PassOwnPtr<RemoteCallFrameId> RemoteCallFrameId::parse(const String& objectId) 45 PassOwnPtr<RemoteCallFrameId> RemoteCallFrameId::parse(const String16& objectId)
46 { 46 {
47 OwnPtr<RemoteCallFrameId> result = adoptPtr(new RemoteCallFrameId()); 47 OwnPtr<RemoteCallFrameId> result = adoptPtr(new RemoteCallFrameId());
48 OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri ptId(objectId); 48 OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScri ptId(objectId);
49 if (!parsedObjectId) 49 if (!parsedObjectId)
50 return nullptr; 50 return nullptr;
51 51
52 bool success = parsedObjectId->getNumber("ordinal", &result->m_frameOrdinal) ; 52 bool success = parsedObjectId->getNumber("ordinal", &result->m_frameOrdinal) ;
53 if (!success) 53 if (!success)
54 return nullptr; 54 return nullptr;
55 55
56 return result.release(); 56 return result.release();
57 } 57 }
58 58
59 } // namespace blink 59 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698