| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sync/test/integration/sync_test.h" | 5 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 "https://www.google.com/accounts/IssueAuthToken"; | 64 "https://www.google.com/accounts/IssueAuthToken"; |
| 65 const char kSearchDomainCheckUrl[] = | 65 const char kSearchDomainCheckUrl[] = |
| 66 "https://www.google.com/searchdomaincheck?format=domain&type=chrome"; | 66 "https://www.google.com/searchdomaincheck?format=domain&type=chrome"; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Helper class that checks whether a sync test server is running or not. | 69 // Helper class that checks whether a sync test server is running or not. |
| 70 class SyncServerStatusChecker : public content::URLFetcherDelegate { | 70 class SyncServerStatusChecker : public content::URLFetcherDelegate { |
| 71 public: | 71 public: |
| 72 SyncServerStatusChecker() : running_(false) {} | 72 SyncServerStatusChecker() : running_(false) {} |
| 73 | 73 |
| 74 virtual void OnURLFetchComplete(const URLFetcher* source) { | 74 virtual void OnURLFetchComplete(const content::URLFetcher* source) { |
| 75 std::string data; | 75 std::string data; |
| 76 source->GetResponseAsString(&data); | 76 source->GetResponseAsString(&data); |
| 77 running_ = (source->status().status() == net::URLRequestStatus::SUCCESS && | 77 running_ = |
| 78 source->response_code() == 200 && data.find("ok") == 0); | 78 (source->GetStatus().status() == net::URLRequestStatus::SUCCESS && |
| 79 source->GetResponseCode() == 200 && data.find("ok") == 0); |
| 79 MessageLoop::current()->Quit(); | 80 MessageLoop::current()->Quit(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 bool running() const { return running_; } | 83 bool running() const { return running_; } |
| 83 | 84 |
| 84 private: | 85 private: |
| 85 bool running_; | 86 bool running_; |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 class SetProxyConfigTask : public Task { | 89 class SetProxyConfigTask : public Task { |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 502 } |
| 502 return false; | 503 return false; |
| 503 } | 504 } |
| 504 | 505 |
| 505 bool SyncTest::IsTestServerRunning() { | 506 bool SyncTest::IsTestServerRunning() { |
| 506 CommandLine* cl = CommandLine::ForCurrentProcess(); | 507 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 507 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL); | 508 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL); |
| 508 GURL sync_url_status(sync_url.append("/healthz")); | 509 GURL sync_url_status(sync_url.append("/healthz")); |
| 509 SyncServerStatusChecker delegate; | 510 SyncServerStatusChecker delegate; |
| 510 URLFetcher fetcher(sync_url_status, URLFetcher::GET, &delegate); | 511 URLFetcher fetcher(sync_url_status, URLFetcher::GET, &delegate); |
| 511 fetcher.set_request_context(Profile::Deprecated::GetDefaultRequestContext()); | 512 fetcher.SetRequestContext(Profile::Deprecated::GetDefaultRequestContext()); |
| 512 fetcher.Start(); | 513 fetcher.Start(); |
| 513 ui_test_utils::RunMessageLoop(); | 514 ui_test_utils::RunMessageLoop(); |
| 514 return delegate.running(); | 515 return delegate.running(); |
| 515 } | 516 } |
| 516 | 517 |
| 517 void SyncTest::EnableNetwork(Profile* profile) { | 518 void SyncTest::EnableNetwork(Profile* profile) { |
| 518 SetProxyConfig(profile->GetRequestContext(), | 519 SetProxyConfig(profile->GetRequestContext(), |
| 519 net::ProxyConfig::CreateDirect()); | 520 net::ProxyConfig::CreateDirect()); |
| 520 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed. | 521 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed. |
| 521 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 522 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 const net::ProxyConfig& proxy_config) { | 704 const net::ProxyConfig& proxy_config) { |
| 704 base::WaitableEvent done(false, false); | 705 base::WaitableEvent done(false, false); |
| 705 BrowserThread::PostTask( | 706 BrowserThread::PostTask( |
| 706 BrowserThread::IO, | 707 BrowserThread::IO, |
| 707 FROM_HERE, | 708 FROM_HERE, |
| 708 new SetProxyConfigTask(&done, | 709 new SetProxyConfigTask(&done, |
| 709 context_getter, | 710 context_getter, |
| 710 proxy_config)); | 711 proxy_config)); |
| 711 done.Wait(); | 712 done.Wait(); |
| 712 } | 713 } |
| OLD | NEW |