OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sync/test/accounts_client/test_accounts_client.h" | 5 #include "sync/test/accounts_client/test_accounts_client.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 static const base::TimeDelta kRequestTimeout = base::TimeDelta::FromSeconds(10); | 32 static const base::TimeDelta kRequestTimeout = base::TimeDelta::FromSeconds(10); |
33 | 33 |
34 AccountSession::AccountSession() {} | 34 AccountSession::AccountSession() {} |
35 AccountSession::~AccountSession() {} | 35 AccountSession::~AccountSession() {} |
36 | 36 |
37 class AccountsRequestDelegate : public net::URLFetcherDelegate { | 37 class AccountsRequestDelegate : public net::URLFetcherDelegate { |
38 public: | 38 public: |
39 AccountsRequestDelegate(base::RunLoop* run_loop) : response_(""), | 39 AccountsRequestDelegate(base::RunLoop* run_loop) : response_(""), |
40 success_(false), run_loop_(run_loop) {} | 40 success_(false), run_loop_(run_loop) {} |
41 | 41 |
42 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { | 42 virtual void OnURLFetchComplete(const net::URLFetcher* source) override { |
43 string url = source->GetURL().spec(); | 43 string url = source->GetURL().spec(); |
44 source->GetResponseAsString(&response_); | 44 source->GetResponseAsString(&response_); |
45 | 45 |
46 if (!source->GetStatus().is_success()) { | 46 if (!source->GetStatus().is_success()) { |
47 int error = source->GetStatus().error(); | 47 int error = source->GetStatus().error(); |
48 DVLOG(0) << "The request failed with error code " << error << "." | 48 DVLOG(0) << "The request failed with error code " << error << "." |
49 << "\nRequested URL: " << url << "."; | 49 << "\nRequested URL: " << url << "."; |
50 } else if (source->GetResponseCode() != net::HTTP_OK) { | 50 } else if (source->GetResponseCode() != net::HTTP_OK) { |
51 DVLOG(0) << "The request failed with response code " | 51 DVLOG(0) << "The request failed with response code " |
52 << source->GetResponseCode() << "." | 52 << source->GetResponseCode() << "." |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 run_loop.QuitClosure(), | 152 run_loop.QuitClosure(), |
153 kRequestTimeout); | 153 kRequestTimeout); |
154 run_loop.Run(); | 154 run_loop.Run(); |
155 | 155 |
156 if (delegate.success()) { | 156 if (delegate.success()) { |
157 *response = delegate.response(); | 157 *response = delegate.response(); |
158 } | 158 } |
159 | 159 |
160 return delegate.success(); | 160 return delegate.success(); |
161 } | 161 } |
OLD | NEW |