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

Side by Side Diff: chrome/browser/google_apis/test_util.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 | Annotate | Revision Log
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/google_apis/test_util.h" 5 #include "chrome/browser/google_apis/test_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 21 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
24 #include "net/test/embedded_test_server/http_request.h" 24 #include "net/test/embedded_test_server/http_request.h"
25 #include "net/test/embedded_test_server/http_response.h" 25 #include "net/test/embedded_test_server/http_response.h"
26 26
27 namespace google_apis { 27 namespace google_apis {
28 namespace test_util { 28 namespace test_util {
29 29
30 // This class is used to monitor if any task is posted to a message loop. 30 // This class is used to monitor if any task is posted to a message loop.
31 class TaskObserver : public MessageLoop::TaskObserver { 31 class TaskObserver : public base::MessageLoop::TaskObserver {
32 public: 32 public:
33 TaskObserver() : posted_(false) {} 33 TaskObserver() : posted_(false) {}
34 virtual ~TaskObserver() {} 34 virtual ~TaskObserver() {}
35 35
36 // MessageLoop::TaskObserver overrides. 36 // MessageLoop::TaskObserver overrides.
37 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE { 37 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
38 } 38 }
39 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE { 39 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
40 posted_ = true; 40 posted_ = true;
41 } 41 }
(...skipping 29 matching lines...) Expand all
71 71
72 GURL GetBaseUrlForTesting(int port) { 72 GURL GetBaseUrlForTesting(int port) {
73 return GURL(base::StringPrintf("http://127.0.0.1:%d/", port)); 73 return GURL(base::StringPrintf("http://127.0.0.1:%d/", port));
74 } 74 }
75 75
76 void RunBlockingPoolTask() { 76 void RunBlockingPoolTask() {
77 while (true) { 77 while (true) {
78 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 78 content::BrowserThread::GetBlockingPool()->FlushForTesting();
79 79
80 TaskObserver task_observer; 80 TaskObserver task_observer;
81 MessageLoop::current()->AddTaskObserver(&task_observer); 81 base::MessageLoop::current()->AddTaskObserver(&task_observer);
82 MessageLoop::current()->RunUntilIdle(); 82 base::MessageLoop::current()->RunUntilIdle();
83 MessageLoop::current()->RemoveTaskObserver(&task_observer); 83 base::MessageLoop::current()->RemoveTaskObserver(&task_observer);
84 if (!task_observer.posted()) 84 if (!task_observer.posted())
85 break; 85 break;
86 } 86 }
87 } 87 }
88 88
89 void RunAndQuit(const base::Closure& closure) { 89 void RunAndQuit(const base::Closure& closure) {
90 closure.Run(); 90 closure.Run();
91 MessageLoop::current()->Quit(); 91 base::MessageLoop::current()->Quit();
92 } 92 }
93 93
94 bool WriteStringToFile(const base::FilePath& file_path, 94 bool WriteStringToFile(const base::FilePath& file_path,
95 const std::string& content) { 95 const std::string& content) {
96 int result = file_util::WriteFile(file_path, content.data(), content.size()); 96 int result = file_util::WriteFile(file_path, content.data(), content.size());
97 return content.size() == static_cast<size_t>(result); 97 return content.size() == static_cast<size_t>(result);
98 } 98 }
99 99
100 bool CreateFileOfSpecifiedSize(const base::FilePath& temp_dir, 100 bool CreateFileOfSpecifiedSize(const base::FilePath& temp_dir,
101 size_t size, 101 size_t size,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return result; 238 return result;
239 } 239 }
240 240
241 void TestGetContentCallback::OnGetContent(google_apis::GDataErrorCode error, 241 void TestGetContentCallback::OnGetContent(google_apis::GDataErrorCode error,
242 scoped_ptr<std::string> data) { 242 scoped_ptr<std::string> data) {
243 data_.push_back(data.release()); 243 data_.push_back(data.release());
244 } 244 }
245 245
246 } // namespace test_util 246 } // namespace test_util
247 } // namespace google_apis 247 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698