| 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 13 matching lines...) Expand all Loading... |
| 24 JsSyncManagerObserver::JsSyncManagerObserver() {} | 24 JsSyncManagerObserver::JsSyncManagerObserver() {} |
| 25 | 25 |
| 26 JsSyncManagerObserver::~JsSyncManagerObserver() {} | 26 JsSyncManagerObserver::~JsSyncManagerObserver() {} |
| 27 | 27 |
| 28 void JsSyncManagerObserver::SetJsEventHandler( | 28 void JsSyncManagerObserver::SetJsEventHandler( |
| 29 const WeakHandle<JsEventHandler>& event_handler) { | 29 const WeakHandle<JsEventHandler>& event_handler) { |
| 30 event_handler_ = event_handler; | 30 event_handler_ = event_handler; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void JsSyncManagerObserver::OnSyncCycleCompleted( | 33 void JsSyncManagerObserver::OnSyncCycleCompleted( |
| 34 const sessions::SyncSessionSnapshot* snapshot) { | 34 const sessions::SyncSessionSnapshot& snapshot) { |
| 35 if (!event_handler_.IsInitialized()) { | 35 if (!event_handler_.IsInitialized()) { |
| 36 return; | 36 return; |
| 37 } | 37 } |
| 38 DictionaryValue details; | 38 DictionaryValue details; |
| 39 details.Set("snapshot", snapshot->ToValue()); | 39 details.Set("snapshot", snapshot.ToValue()); |
| 40 HandleJsEvent(FROM_HERE, "onSyncCycleCompleted", JsEventDetails(&details)); | 40 HandleJsEvent(FROM_HERE, "onSyncCycleCompleted", JsEventDetails(&details)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void JsSyncManagerObserver::OnConnectionStatusChange( | 43 void JsSyncManagerObserver::OnConnectionStatusChange( |
| 44 sync_api::ConnectionStatus status) { | 44 sync_api::ConnectionStatus status) { |
| 45 if (!event_handler_.IsInitialized()) { | 45 if (!event_handler_.IsInitialized()) { |
| 46 return; | 46 return; |
| 47 } | 47 } |
| 48 DictionaryValue details; | 48 DictionaryValue details; |
| 49 details.SetString("status", sync_api::ConnectionStatusToString(status)); | 49 details.SetString("status", sync_api::ConnectionStatusToString(status)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 const std::string& name, const JsEventDetails& details) { | 160 const std::string& name, const JsEventDetails& details) { |
| 161 if (!event_handler_.IsInitialized()) { | 161 if (!event_handler_.IsInitialized()) { |
| 162 NOTREACHED(); | 162 NOTREACHED(); |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 event_handler_.Call(from_here, | 165 event_handler_.Call(from_here, |
| 166 &JsEventHandler::HandleJsEvent, name, details); | 166 &JsEventHandler::HandleJsEvent, name, details); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace browser_sync | 169 } // namespace browser_sync |
| OLD | NEW |