| 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/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 ERROR_REASON_BACKEND_INIT_FAILURE); | 933 ERROR_REASON_BACKEND_INIT_FAILURE); |
| 934 return; | 934 return; |
| 935 } | 935 } |
| 936 | 936 |
| 937 backend_initialized_ = true; | 937 backend_initialized_ = true; |
| 938 | 938 |
| 939 sync_js_controller_.AttachJsBackend(js_backend); | 939 sync_js_controller_.AttachJsBackend(js_backend); |
| 940 debug_info_listener_ = debug_info_listener; | 940 debug_info_listener_ = debug_info_listener; |
| 941 | 941 |
| 942 if (protocol_event_observers_.might_have_observers()) { | 942 if (protocol_event_observers_.might_have_observers()) { |
| 943 backend_->SetForwardProtocolEvents(true); | 943 backend_->RequestBufferedProtocolEventsAndEnableForwarding(); |
| 944 } | 944 } |
| 945 | 945 |
| 946 // If we have a cached passphrase use it to decrypt/encrypt data now that the | 946 // If we have a cached passphrase use it to decrypt/encrypt data now that the |
| 947 // backend is initialized. We want to call this before notifying observers in | 947 // backend is initialized. We want to call this before notifying observers in |
| 948 // case this operation affects the "passphrase required" status. | 948 // case this operation affects the "passphrase required" status. |
| 949 ConsumeCachedPassphraseIfPossible(); | 949 ConsumeCachedPassphraseIfPossible(); |
| 950 | 950 |
| 951 // The very first time the backend initializes is effectively the first time | 951 // The very first time the backend initializes is effectively the first time |
| 952 // we can say we successfully "synced". last_synced_time_ will only be null | 952 // we can say we successfully "synced". last_synced_time_ will only be null |
| 953 // in this case, because the pref wasn't restored on StartUp. | 953 // in this case, because the pref wasn't restored on StartUp. |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 | 2064 |
| 2065 void ProfileSyncService::RemoveObserver( | 2065 void ProfileSyncService::RemoveObserver( |
| 2066 ProfileSyncServiceBase::Observer* observer) { | 2066 ProfileSyncServiceBase::Observer* observer) { |
| 2067 observers_.RemoveObserver(observer); | 2067 observers_.RemoveObserver(observer); |
| 2068 } | 2068 } |
| 2069 | 2069 |
| 2070 void ProfileSyncService::AddProtocolEventObserver( | 2070 void ProfileSyncService::AddProtocolEventObserver( |
| 2071 browser_sync::ProtocolEventObserver* observer) { | 2071 browser_sync::ProtocolEventObserver* observer) { |
| 2072 protocol_event_observers_.AddObserver(observer); | 2072 protocol_event_observers_.AddObserver(observer); |
| 2073 if (backend_) { | 2073 if (backend_) { |
| 2074 backend_->SetForwardProtocolEvents( | 2074 backend_->RequestBufferedProtocolEventsAndEnableForwarding(); |
| 2075 protocol_event_observers_.might_have_observers()); | |
| 2076 } | 2075 } |
| 2077 } | 2076 } |
| 2078 | 2077 |
| 2079 void ProfileSyncService::RemoveProtocolEventObserver( | 2078 void ProfileSyncService::RemoveProtocolEventObserver( |
| 2080 browser_sync::ProtocolEventObserver* observer) { | 2079 browser_sync::ProtocolEventObserver* observer) { |
| 2081 protocol_event_observers_.RemoveObserver(observer); | 2080 protocol_event_observers_.RemoveObserver(observer); |
| 2082 if (backend_) { | 2081 if (backend_ && !protocol_event_observers_.might_have_observers()) { |
| 2083 backend_->SetForwardProtocolEvents( | 2082 backend_->DisableProtocolEventForwarding(); |
| 2084 protocol_event_observers_.might_have_observers()); | |
| 2085 } | 2083 } |
| 2086 } | 2084 } |
| 2087 | 2085 |
| 2088 bool ProfileSyncService::HasObserver( | 2086 bool ProfileSyncService::HasObserver( |
| 2089 ProfileSyncServiceBase::Observer* observer) const { | 2087 ProfileSyncServiceBase::Observer* observer) const { |
| 2090 return observers_.HasObserver(observer); | 2088 return observers_.HasObserver(observer); |
| 2091 } | 2089 } |
| 2092 | 2090 |
| 2093 base::WeakPtr<syncer::JsController> ProfileSyncService::GetJsController() { | 2091 base::WeakPtr<syncer::JsController> ProfileSyncService::GetJsController() { |
| 2094 return sync_js_controller_.AsWeakPtr(); | 2092 return sync_js_controller_.AsWeakPtr(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2221 status.last_get_token_error = last_get_token_error_; | 2219 status.last_get_token_error = last_get_token_error_; |
| 2222 if (request_access_token_retry_timer_.IsRunning()) | 2220 if (request_access_token_retry_timer_.IsRunning()) |
| 2223 status.next_token_request_time = next_token_request_time_; | 2221 status.next_token_request_time = next_token_request_time_; |
| 2224 return status; | 2222 return status; |
| 2225 } | 2223 } |
| 2226 | 2224 |
| 2227 void ProfileSyncService::OverrideNetworkResourcesForTest( | 2225 void ProfileSyncService::OverrideNetworkResourcesForTest( |
| 2228 scoped_ptr<syncer::NetworkResources> network_resources) { | 2226 scoped_ptr<syncer::NetworkResources> network_resources) { |
| 2229 network_resources_ = network_resources.Pass(); | 2227 network_resources_ = network_resources.Pass(); |
| 2230 } | 2228 } |
| OLD | NEW |