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

Side by Side Diff: content/public/test/test_utils.cc

Issue 1544293002: Convert Pass()→std::move() in //content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 "content/public/test/test_utils.h" 5 #include "content/public/test/test_utils.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/location.h" 11 #include "base/location.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/run_loop.h" 13 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
13 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
14 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
15 #include "base/values.h" 17 #include "base/values.h"
16 #include "build/build_config.h" 18 #include "build/build_config.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 BrowserThread::PostTask(thread_id, FROM_HERE, quit_task); 63 BrowserThread::PostTask(thread_id, FROM_HERE, quit_task);
62 } 64 }
63 65
64 // Class used to handle result callbacks for ExecuteScriptAndGetValue. 66 // Class used to handle result callbacks for ExecuteScriptAndGetValue.
65 class ScriptCallback { 67 class ScriptCallback {
66 public: 68 public:
67 ScriptCallback() { } 69 ScriptCallback() { }
68 virtual ~ScriptCallback() { } 70 virtual ~ScriptCallback() { }
69 void ResultCallback(const base::Value* result); 71 void ResultCallback(const base::Value* result);
70 72
71 scoped_ptr<base::Value> result() { return result_.Pass(); } 73 scoped_ptr<base::Value> result() { return std::move(result_); }
72 74
73 private: 75 private:
74 scoped_ptr<base::Value> result_; 76 scoped_ptr<base::Value> result_;
75 77
76 DISALLOW_COPY_AND_ASSIGN(ScriptCallback); 78 DISALLOW_COPY_AND_ASSIGN(ScriptCallback);
77 }; 79 };
78 80
79 void ScriptCallback::ResultCallback(const base::Value* result) { 81 void ScriptCallback::ResultCallback(const base::Value* result) {
80 if (result) 82 if (result)
81 result_.reset(result->DeepCopy()); 83 result_.reset(result->DeepCopy());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 185
184 scoped_ptr<base::Value> ExecuteScriptAndGetValue( 186 scoped_ptr<base::Value> ExecuteScriptAndGetValue(
185 RenderFrameHost* render_frame_host, const std::string& script) { 187 RenderFrameHost* render_frame_host, const std::string& script) {
186 ScriptCallback observer; 188 ScriptCallback observer;
187 189
188 render_frame_host->ExecuteJavaScriptForTests( 190 render_frame_host->ExecuteJavaScriptForTests(
189 base::UTF8ToUTF16(script), 191 base::UTF8ToUTF16(script),
190 base::Bind(&ScriptCallback::ResultCallback, base::Unretained(&observer))); 192 base::Bind(&ScriptCallback::ResultCallback, base::Unretained(&observer)));
191 base::MessageLoop* loop = base::MessageLoop::current(); 193 base::MessageLoop* loop = base::MessageLoop::current();
192 loop->Run(); 194 loop->Run();
193 return observer.result().Pass(); 195 return observer.result();
194 } 196 }
195 197
196 bool AreAllSitesIsolatedForTesting() { 198 bool AreAllSitesIsolatedForTesting() {
197 return base::CommandLine::ForCurrentProcess()->HasSwitch( 199 return base::CommandLine::ForCurrentProcess()->HasSwitch(
198 switches::kSitePerProcess); 200 switches::kSitePerProcess);
199 } 201 }
200 202
201 void IsolateAllSitesForTesting(base::CommandLine* command_line) { 203 void IsolateAllSitesForTesting(base::CommandLine* command_line) {
202 command_line->AppendSwitch(switches::kSitePerProcess); 204 command_line->AppendSwitch(switches::kSitePerProcess);
203 } 205 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 382
381 void WebContentsDestroyedWatcher::Wait() { 383 void WebContentsDestroyedWatcher::Wait() {
382 message_loop_runner_->Run(); 384 message_loop_runner_->Run();
383 } 385 }
384 386
385 void WebContentsDestroyedWatcher::WebContentsDestroyed() { 387 void WebContentsDestroyedWatcher::WebContentsDestroyed() {
386 message_loop_runner_->Quit(); 388 message_loop_runner_->Quit();
387 } 389 }
388 390
389 } // namespace content 391 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_mojo_app.cc ('k') | content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698