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