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

Side by Side Diff: chrome/browser/extensions/extension_function_test_utils.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_function_test_utils.h" 5 #include "chrome/browser/extensions/extension_function_test_utils.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 WebContents* GetAssociatedWebContents() const override { return NULL; } 43 WebContents* GetAssociatedWebContents() const override { return NULL; }
44 44
45 Browser* browser_; 45 Browser* browser_;
46 }; 46 };
47 47
48 } // namespace 48 } // namespace
49 49
50 namespace extension_function_test_utils { 50 namespace extension_function_test_utils {
51 51
52 base::ListValue* ParseList(const std::string& data) { 52 base::ListValue* ParseList(const std::string& data) {
53 scoped_ptr<base::Value> result = base::JSONReader::Read(data); 53 std::unique_ptr<base::Value> result = base::JSONReader::Read(data);
54 base::ListValue* list = NULL; 54 base::ListValue* list = NULL;
55 result->GetAsList(&list); 55 result->GetAsList(&list);
56 ignore_result(result.release()); 56 ignore_result(result.release());
57 return list; 57 return list;
58 } 58 }
59 59
60 base::DictionaryValue* ToDictionary(base::Value* val) { 60 base::DictionaryValue* ToDictionary(base::Value* val) {
61 EXPECT_TRUE(val); 61 EXPECT_TRUE(val);
62 EXPECT_EQ(base::Value::TYPE_DICTIONARY, val->GetType()); 62 EXPECT_EQ(base::Value::TYPE_DICTIONARY, val->GetType());
63 return static_cast<base::DictionaryValue*>(val); 63 return static_cast<base::DictionaryValue*>(val);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ASSERT_FALSE(bad_message); 148 ASSERT_FALSE(bad_message);
149 ASSERT_FALSE(HasResponse()); 149 ASSERT_FALSE(HasResponse());
150 response_.reset(new bool); 150 response_.reset(new bool);
151 *response_ = success; 151 *response_ = success;
152 if (should_post_quit_) { 152 if (should_post_quit_) {
153 base::MessageLoopForUI::current()->QuitWhenIdle(); 153 base::MessageLoopForUI::current()->QuitWhenIdle();
154 } 154 }
155 } 155 }
156 156
157 private: 157 private:
158 scoped_ptr<bool> response_; 158 std::unique_ptr<bool> response_;
159 bool should_post_quit_; 159 bool should_post_quit_;
160 }; 160 };
161 161
162 bool RunFunction(UIThreadExtensionFunction* function, 162 bool RunFunction(UIThreadExtensionFunction* function,
163 const std::string& args, 163 const std::string& args,
164 Browser* browser, 164 Browser* browser,
165 RunFunctionFlags flags) { 165 RunFunctionFlags flags) {
166 scoped_ptr<base::ListValue> parsed_args(ParseList(args)); 166 std::unique_ptr<base::ListValue> parsed_args(ParseList(args));
167 EXPECT_TRUE(parsed_args.get()) 167 EXPECT_TRUE(parsed_args.get())
168 << "Could not parse extension function arguments: " << args; 168 << "Could not parse extension function arguments: " << args;
169 return RunFunction(function, std::move(parsed_args), browser, flags); 169 return RunFunction(function, std::move(parsed_args), browser, flags);
170 } 170 }
171 171
172 bool RunFunction(UIThreadExtensionFunction* function, 172 bool RunFunction(UIThreadExtensionFunction* function,
173 scoped_ptr<base::ListValue> args, 173 std::unique_ptr<base::ListValue> args,
174 Browser* browser, 174 Browser* browser,
175 RunFunctionFlags flags) { 175 RunFunctionFlags flags) {
176 TestFunctionDispatcherDelegate dispatcher_delegate(browser); 176 TestFunctionDispatcherDelegate dispatcher_delegate(browser);
177 scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher( 177 std::unique_ptr<extensions::ExtensionFunctionDispatcher> dispatcher(
178 new extensions::ExtensionFunctionDispatcher(browser->profile())); 178 new extensions::ExtensionFunctionDispatcher(browser->profile()));
179 dispatcher->set_delegate(&dispatcher_delegate); 179 dispatcher->set_delegate(&dispatcher_delegate);
180 // TODO(yoz): The cast is a hack; these flags should be defined in 180 // TODO(yoz): The cast is a hack; these flags should be defined in
181 // only one place. See crbug.com/394840. 181 // only one place. See crbug.com/394840.
182 return extensions::api_test_utils::RunFunction( 182 return extensions::api_test_utils::RunFunction(
183 function, std::move(args), browser->profile(), std::move(dispatcher), 183 function, std::move(args), browser->profile(), std::move(dispatcher),
184 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags)); 184 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags));
185 } 185 }
186 186
187 } // namespace extension_function_test_utils 187 } // namespace extension_function_test_utils
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_test_utils.h ('k') | chrome/browser/extensions/extension_garbage_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698