| 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 "sync/internal_api/js_sync_manager_observer.h" | 5 #include "sync/internal_api/js_sync_manager_observer.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 DictionaryValue details; | 122 DictionaryValue details; |
| 123 details.Set("syncError", sync_error.ToValue()); | 123 details.Set("syncError", sync_error.ToValue()); |
| 124 HandleJsEvent(FROM_HERE, "onActionableError", | 124 HandleJsEvent(FROM_HERE, "onActionableError", |
| 125 JsEventDetails(&details)); | 125 JsEventDetails(&details)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void JsSyncManagerObserver::OnInitializationComplete( | 128 void JsSyncManagerObserver::OnInitializationComplete( |
| 129 const WeakHandle<JsBackend>& js_backend, | 129 const WeakHandle<JsBackend>& js_backend, |
| 130 bool success) { | 130 bool success, syncer::ModelTypeSet restored_types) { |
| 131 if (!event_handler_.IsInitialized()) { | 131 if (!event_handler_.IsInitialized()) { |
| 132 return; | 132 return; |
| 133 } | 133 } |
| 134 // Ignore the |js_backend| argument; it's not really convertible to | 134 // Ignore the |js_backend| argument; it's not really convertible to |
| 135 // JSON anyway. | 135 // JSON anyway. |
| 136 HandleJsEvent(FROM_HERE, "onInitializationComplete", JsEventDetails()); | 136 |
| 137 DictionaryValue* details = new DictionaryValue(); |
| 138 details->Set("restoredTypes", ModelTypeSetToValue(restored_types)); |
| 139 |
| 140 HandleJsEvent(FROM_HERE, "onInitializationComplete", JsEventDetails(details)); |
| 137 } | 141 } |
| 138 | 142 |
| 139 void JsSyncManagerObserver::OnStopSyncingPermanently() { | 143 void JsSyncManagerObserver::OnStopSyncingPermanently() { |
| 140 if (!event_handler_.IsInitialized()) { | 144 if (!event_handler_.IsInitialized()) { |
| 141 return; | 145 return; |
| 142 } | 146 } |
| 143 HandleJsEvent(FROM_HERE, "onStopSyncingPermanently", JsEventDetails()); | 147 HandleJsEvent(FROM_HERE, "onStopSyncingPermanently", JsEventDetails()); |
| 144 } | 148 } |
| 145 | 149 |
| 146 void JsSyncManagerObserver::HandleJsEvent( | 150 void JsSyncManagerObserver::HandleJsEvent( |
| 147 const tracked_objects::Location& from_here, | 151 const tracked_objects::Location& from_here, |
| 148 const std::string& name, const JsEventDetails& details) { | 152 const std::string& name, const JsEventDetails& details) { |
| 149 if (!event_handler_.IsInitialized()) { | 153 if (!event_handler_.IsInitialized()) { |
| 150 NOTREACHED(); | 154 NOTREACHED(); |
| 151 return; | 155 return; |
| 152 } | 156 } |
| 153 event_handler_.Call(from_here, | 157 event_handler_.Call(from_here, |
| 154 &JsEventHandler::HandleJsEvent, name, details); | 158 &JsEventHandler::HandleJsEvent, name, details); |
| 155 } | 159 } |
| 156 | 160 |
| 157 } // namespace syncer | 161 } // namespace syncer |
| OLD | NEW |