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

Side by Side Diff: chrome/browser/chromeos/login/mock_url_fetchers.cc

Issue 3407008: [Chrome OS] Infrastucture for doing offline/online login simultaneously (Closed)
Patch Set: re-upload (again) due to 500s Created 10 years, 3 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
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/mock_url_fetchers.h"
6
7 #include "base/message_loop.h"
8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/common/net/url_fetcher.h"
10 #include "googleurl/src/gurl.h"
11 #include "net/url_request/url_request_status.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace chromeos {
15
16 ExpectCanceledFetcher::ExpectCanceledFetcher(
17 bool success,
18 const GURL& url,
19 const std::string& results,
20 URLFetcher::RequestType request_type,
21 URLFetcher::Delegate* d)
22 : URLFetcher(url, request_type, d) {
23 }
24
25 ExpectCanceledFetcher::~ExpectCanceledFetcher() {
26 task_->Cancel();
27 }
28
29 void ExpectCanceledFetcher::Start() {
30 LOG(INFO) << "Delaying fetch completion in mock";
31 task_ = NewRunnableFunction(&ExpectCanceledFetcher::CompleteFetch);
32 ChromeThread::PostDelayedTask(ChromeThread::UI,
33 FROM_HERE,
34 task_,
35 100);
36 }
37
38 // static
39 void ExpectCanceledFetcher::CompleteFetch() {
40 ADD_FAILURE() << "Fetch completed in ExpectCanceledFetcher!";
41 MessageLoop::current()->Quit(); // Allow exiting even if we mess up.
42 }
43
44 GotCanceledFetcher::GotCanceledFetcher(bool success,
45 const GURL& url,
46 const std::string& results,
47 URLFetcher::RequestType request_type,
48 URLFetcher::Delegate* d)
49 : URLFetcher(url, request_type, d),
50 url_(url) {
51 LOG(INFO) << url_.spec();
52 }
53
54 GotCanceledFetcher::~GotCanceledFetcher() {}
55
56 void GotCanceledFetcher::Start() {
57 URLRequestStatus status;
58 status.set_status(URLRequestStatus::CANCELED);
59 delegate()->OnURLFetchComplete(this,
60 url_,
61 status,
62 403,
63 ResponseCookies(),
64 std::string());
65 }
66
67 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/mock_url_fetchers.h ('k') | chrome/browser/chromeos/login/online_attempt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698