| OLD | NEW |
| 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/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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const char kSyncServerCommandLine[] = "sync-server-command-line"; | 94 const char kSyncServerCommandLine[] = "sync-server-command-line"; |
| 95 } | 95 } |
| 96 | 96 |
| 97 namespace { | 97 namespace { |
| 98 | 98 |
| 99 // Helper class that checks whether a sync test server is running or not. | 99 // Helper class that checks whether a sync test server is running or not. |
| 100 class SyncServerStatusChecker : public net::URLFetcherDelegate { | 100 class SyncServerStatusChecker : public net::URLFetcherDelegate { |
| 101 public: | 101 public: |
| 102 SyncServerStatusChecker() : running_(false) {} | 102 SyncServerStatusChecker() : running_(false) {} |
| 103 | 103 |
| 104 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { | 104 virtual void OnURLFetchComplete(const net::URLFetcher* source) override { |
| 105 std::string data; | 105 std::string data; |
| 106 source->GetResponseAsString(&data); | 106 source->GetResponseAsString(&data); |
| 107 running_ = | 107 running_ = |
| 108 (source->GetStatus().status() == net::URLRequestStatus::SUCCESS && | 108 (source->GetStatus().status() == net::URLRequestStatus::SUCCESS && |
| 109 source->GetResponseCode() == 200 && data.find("ok") == 0); | 109 source->GetResponseCode() == 200 && data.find("ok") == 0); |
| 110 base::MessageLoop::current()->Quit(); | 110 base::MessageLoop::current()->Quit(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool running() const { return running_; } | 113 bool running() const { return running_; } |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 bool running_; | 116 bool running_; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 bool IsEncryptionComplete(const ProfileSyncService* service) { | 119 bool IsEncryptionComplete(const ProfileSyncService* service) { |
| 120 return service->EncryptEverythingEnabled() && !service->encryption_pending(); | 120 return service->EncryptEverythingEnabled() && !service->encryption_pending(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Helper class to wait for encryption to complete. | 123 // Helper class to wait for encryption to complete. |
| 124 class EncryptionChecker : public SingleClientStatusChangeChecker { | 124 class EncryptionChecker : public SingleClientStatusChangeChecker { |
| 125 public: | 125 public: |
| 126 explicit EncryptionChecker(ProfileSyncService* service) | 126 explicit EncryptionChecker(ProfileSyncService* service) |
| 127 : SingleClientStatusChangeChecker(service) {} | 127 : SingleClientStatusChangeChecker(service) {} |
| 128 | 128 |
| 129 virtual bool IsExitConditionSatisfied() OVERRIDE { | 129 virtual bool IsExitConditionSatisfied() override { |
| 130 return IsEncryptionComplete(service()); | 130 return IsEncryptionComplete(service()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 virtual std::string GetDebugMessage() const OVERRIDE { | 133 virtual std::string GetDebugMessage() const override { |
| 134 return "Encryption"; | 134 return "Encryption"; |
| 135 } | 135 } |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 void SetupNetworkCallback( | 138 void SetupNetworkCallback( |
| 139 base::WaitableEvent* done, | 139 base::WaitableEvent* done, |
| 140 net::URLRequestContextGetter* url_request_context_getter) { | 140 net::URLRequestContextGetter* url_request_context_getter) { |
| 141 url_request_context_getter->GetURLRequestContext()-> | 141 url_request_context_getter->GetURLRequestContext()-> |
| 142 set_cookie_store(new net::CookieMonster(NULL, NULL)); | 142 set_cookie_store(new net::CookieMonster(NULL, NULL)); |
| 143 done->Signal(); | 143 done->Signal(); |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 BrowserThread::PostTask( | 1072 BrowserThread::PostTask( |
| 1073 BrowserThread::IO, FROM_HERE, | 1073 BrowserThread::IO, FROM_HERE, |
| 1074 base::Bind(&SetProxyConfigCallback, &done, | 1074 base::Bind(&SetProxyConfigCallback, &done, |
| 1075 make_scoped_refptr(context_getter), proxy_config)); | 1075 make_scoped_refptr(context_getter), proxy_config)); |
| 1076 done.Wait(); | 1076 done.Wait(); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 fake_server::FakeServer* SyncTest::GetFakeServer() const { | 1079 fake_server::FakeServer* SyncTest::GetFakeServer() const { |
| 1080 return fake_server_.get(); | 1080 return fake_server_.get(); |
| 1081 } | 1081 } |
| OLD | NEW |