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

Side by Side Diff: chrome/browser/devtools/devtools_embedder_message_dispatcher.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" 5 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 9
10 namespace { 10 namespace {
11 11
12 using DispatchCallback = DevToolsEmbedderMessageDispatcher::DispatchCallback; 12 using DispatchCallback = DevToolsEmbedderMessageDispatcher::DispatchCallback;
13 13
14 bool GetValue(const base::Value* value, std::string* result) { 14 bool GetValue(const base::Value& value, std::string* result) {
15 return value->GetAsString(result); 15 return value.GetAsString(result);
16 } 16 }
17 17
18 bool GetValue(const base::Value* value, int* result) { 18 bool GetValue(const base::Value& value, int* result) {
19 return value->GetAsInteger(result); 19 return value.GetAsInteger(result);
20 } 20 }
21 21
22 bool GetValue(const base::Value* value, bool* result) { 22 bool GetValue(const base::Value& value, bool* result) {
23 return value->GetAsBoolean(result); 23 return value.GetAsBoolean(result);
24 } 24 }
25 25
26 bool GetValue(const base::Value* value, gfx::Rect* rect) { 26 bool GetValue(const base::Value& value, gfx::Rect* rect) {
27 const base::DictionaryValue* dict; 27 const base::DictionaryValue* dict;
28 if (!value->GetAsDictionary(&dict)) 28 if (!value.GetAsDictionary(&dict))
29 return false; 29 return false;
30 int x = 0; 30 int x = 0;
31 int y = 0; 31 int y = 0;
32 int width = 0; 32 int width = 0;
33 int height = 0; 33 int height = 0;
34 if (!dict->GetInteger("x", &x) || 34 if (!dict->GetInteger("x", &x) ||
35 !dict->GetInteger("y", &y) || 35 !dict->GetInteger("y", &y) ||
36 !dict->GetInteger("width", &width) || 36 !dict->GetInteger("width", &width) ||
37 !dict->GetInteger("height", &height)) 37 !dict->GetInteger("height", &height))
38 return false; 38 return false;
(...skipping 21 matching lines...) Expand all
60 template <typename H, typename... As> 60 template <typename H, typename... As>
61 void Apply(const H& handler, As... args) { 61 void Apply(const H& handler, As... args) {
62 handler.Run(args...); 62 handler.Run(args...);
63 } 63 }
64 }; 64 };
65 65
66 template <typename T, typename... Ts> 66 template <typename T, typename... Ts>
67 struct ParamTuple<T, Ts...> { 67 struct ParamTuple<T, Ts...> {
68 bool Parse(const base::ListValue& list, 68 bool Parse(const base::ListValue& list,
69 const base::ListValue::const_iterator& it) { 69 const base::ListValue::const_iterator& it) {
70 return it != list.end() && GetValue(*it, &head) && tail.Parse(list, it + 1); 70 return it != list.end() && GetValue(**it, &head) &&
71 tail.Parse(list, it + 1);
71 } 72 }
72 73
73 template <typename H, typename... As> 74 template <typename H, typename... As>
74 void Apply(const H& handler, As... args) { 75 void Apply(const H& handler, As... args) {
75 tail.template Apply<H, As..., T>(handler, args..., head); 76 tail.template Apply<H, As..., T>(handler, args..., head);
76 } 77 }
77 78
78 typename StorageTraits<T>::StorageType head; 79 typename StorageTraits<T>::StorageType head;
79 ParamTuple<Ts...> tail; 80 ParamTuple<Ts...> tail;
80 }; 81 };
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 d->RegisterHandler("setPreference", 206 d->RegisterHandler("setPreference",
206 &Delegate::SetPreference, delegate); 207 &Delegate::SetPreference, delegate);
207 d->RegisterHandler("removePreference", 208 d->RegisterHandler("removePreference",
208 &Delegate::RemovePreference, delegate); 209 &Delegate::RemovePreference, delegate);
209 d->RegisterHandler("clearPreferences", 210 d->RegisterHandler("clearPreferences",
210 &Delegate::ClearPreferences, delegate); 211 &Delegate::ClearPreferences, delegate);
211 d->RegisterHandler("readyForTest", 212 d->RegisterHandler("readyForTest",
212 &Delegate::ReadyForTest, delegate); 213 &Delegate::ReadyForTest, delegate);
213 return d; 214 return d;
214 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698