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

Side by Side Diff: chrome/browser/chromeos/contacts/gdata_contacts_service_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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/chromeos/contacts/gdata_contacts_service.h" 5 #include "chrome/browser/chromeos/contacts/gdata_contacts_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // at a file on |test_server_|. 144 // at a file on |test_server_|.
145 std::string RewritePhotoUrl(const std::string& original_url) { 145 std::string RewritePhotoUrl(const std::string& original_url) {
146 return test_server_->GetURL(GURL(original_url).path()).spec(); 146 return test_server_->GetURL(GURL(original_url).path()).spec();
147 } 147 }
148 148
149 // Handles success for Download(). 149 // Handles success for Download().
150 void OnSuccess(scoped_ptr<ScopedVector<contacts::Contact> > contacts) { 150 void OnSuccess(scoped_ptr<ScopedVector<contacts::Contact> > contacts) {
151 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 151 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
152 download_was_successful_ = true; 152 download_was_successful_ = true;
153 downloaded_contacts_.swap(contacts); 153 downloaded_contacts_.swap(contacts);
154 MessageLoop::current()->Quit(); 154 base::MessageLoop::current()->Quit();
155 } 155 }
156 156
157 // Handles failure for Download(). 157 // Handles failure for Download().
158 void OnFailure() { 158 void OnFailure() {
159 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 159 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
160 download_was_successful_ = false; 160 download_was_successful_ = false;
161 downloaded_contacts_.reset(new ScopedVector<contacts::Contact>()); 161 downloaded_contacts_.reset(new ScopedVector<contacts::Contact>());
162 MessageLoop::current()->Quit(); 162 base::MessageLoop::current()->Quit();
163 } 163 }
164 164
165 // Handles a request for downloading a file. Reads a requested file and 165 // Handles a request for downloading a file. Reads a requested file and
166 // returns the content. 166 // returns the content.
167 scoped_ptr<google_apis::test_server::HttpResponse> HandleDownloadRequest( 167 scoped_ptr<google_apis::test_server::HttpResponse> HandleDownloadRequest(
168 const google_apis::test_server::HttpRequest& request) { 168 const google_apis::test_server::HttpRequest& request) {
169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
170 // Requested url must not contain a query string. 170 // Requested url must not contain a query string.
171 scoped_ptr<google_apis::test_server::HttpResponse> result = 171 scoped_ptr<google_apis::test_server::HttpResponse> result =
172 google_apis::test_util::CreateHttpResponseFromFile( 172 google_apis::test_util::CreateHttpResponseFromFile(
173 google_apis::test_util::GetTestFilePath( 173 google_apis::test_util::GetTestFilePath(
174 std::string("chromeos/gdata/contacts") + request.relative_url)); 174 std::string("chromeos/gdata/contacts") + request.relative_url));
175 return result.Pass(); 175 return result.Pass();
176 } 176 }
177 177
178 MessageLoopForUI message_loop_; 178 base::MessageLoopForUI message_loop_;
179 content::TestBrowserThread ui_thread_; 179 content::TestBrowserThread ui_thread_;
180 content::TestBrowserThread io_thread_; 180 content::TestBrowserThread io_thread_;
181 scoped_ptr<TestingProfile> profile_; 181 scoped_ptr<TestingProfile> profile_;
182 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; 182 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
183 183
184 // Was the last download successful? Used to pass the result back from 184 // Was the last download successful? Used to pass the result back from
185 // OnSuccess() and OnFailure() to Download(). 185 // OnSuccess() and OnFailure() to Download().
186 bool download_was_successful_; 186 bool download_was_successful_;
187 187
188 // Used to pass downloaded contacts back to Download(). 188 // Used to pass downloaded contacts back to Download().
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 scoped_ptr<contacts::Contact> contact2(new contacts::Contact); 337 scoped_ptr<contacts::Contact> contact2(new contacts::Contact);
338 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z", 338 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z",
339 false, "Bob Smith", "Bob", "", "Smith", "", "", 339 false, "Bob Smith", "Bob", "", "Smith", "", "",
340 contact2.get()); 340 contact2.get());
341 EXPECT_EQ(contacts::test::VarContactsToString( 341 EXPECT_EQ(contacts::test::VarContactsToString(
342 2, contact1.get(), contact2.get()), 342 2, contact1.get(), contact2.get()),
343 contacts::test::ContactsToString(*contacts)); 343 contacts::test::ContactsToString(*contacts));
344 } 344 }
345 345
346 } // namespace contacts 346 } // namespace contacts
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698