Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: components/sync/core_impl/js_sync_manager_observer.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/sync/core_impl/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"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "sync/internal_api/public/base/model_type.h" 13 #include "components/sync/base/model_type.h"
14 #include "sync/internal_api/public/change_record.h" 14 #include "components/sync/base/sync_string_conversions.h"
15 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 15 #include "components/sync/core/change_record.h"
16 #include "sync/internal_api/public/util/sync_string_conversions.h" 16 #include "components/sync/js/js_event_details.h"
17 #include "sync/js/js_event_details.h" 17 #include "components/sync/js/js_event_handler.h"
18 #include "sync/js/js_event_handler.h" 18 #include "components/sync/sessions/sync_session_snapshot.h"
19 19
20 namespace syncer { 20 namespace syncer {
21 21
22 JsSyncManagerObserver::JsSyncManagerObserver() {} 22 JsSyncManagerObserver::JsSyncManagerObserver() {}
23 23
24 JsSyncManagerObserver::~JsSyncManagerObserver() {} 24 JsSyncManagerObserver::~JsSyncManagerObserver() {}
25 25
26 void JsSyncManagerObserver::SetJsEventHandler( 26 void JsSyncManagerObserver::SetJsEventHandler(
27 const WeakHandle<JsEventHandler>& event_handler) { 27 const WeakHandle<JsEventHandler>& event_handler) {
28 event_handler_ = event_handler; 28 event_handler_ = event_handler;
29 } 29 }
30 30
31 void JsSyncManagerObserver::OnSyncCycleCompleted( 31 void JsSyncManagerObserver::OnSyncCycleCompleted(
32 const sessions::SyncSessionSnapshot& snapshot) { 32 const sessions::SyncSessionSnapshot& snapshot) {
33 if (!event_handler_.IsInitialized()) { 33 if (!event_handler_.IsInitialized()) {
34 return; 34 return;
35 } 35 }
36 base::DictionaryValue details; 36 base::DictionaryValue details;
37 details.Set("snapshot", snapshot.ToValue()); 37 details.Set("snapshot", snapshot.ToValue());
38 HandleJsEvent(FROM_HERE, "onSyncCycleCompleted", JsEventDetails(&details)); 38 HandleJsEvent(FROM_HERE, "onSyncCycleCompleted", JsEventDetails(&details));
39 } 39 }
40 40
41 void JsSyncManagerObserver::OnConnectionStatusChange(ConnectionStatus status) { 41 void JsSyncManagerObserver::OnConnectionStatusChange(ConnectionStatus status) {
42 if (!event_handler_.IsInitialized()) { 42 if (!event_handler_.IsInitialized()) {
43 return; 43 return;
44 } 44 }
45 base::DictionaryValue details; 45 base::DictionaryValue details;
46 details.SetString("status", ConnectionStatusToString(status)); 46 details.SetString("status", ConnectionStatusToString(status));
47 HandleJsEvent(FROM_HERE, 47 HandleJsEvent(FROM_HERE, "onConnectionStatusChange",
48 "onConnectionStatusChange", JsEventDetails(&details)); 48 JsEventDetails(&details));
49 } 49 }
50 50
51 void JsSyncManagerObserver::OnActionableError( 51 void JsSyncManagerObserver::OnActionableError(
52 const SyncProtocolError& sync_error) { 52 const SyncProtocolError& sync_error) {
53 if (!event_handler_.IsInitialized()) { 53 if (!event_handler_.IsInitialized()) {
54 return; 54 return;
55 } 55 }
56 base::DictionaryValue details; 56 base::DictionaryValue details;
57 details.Set("syncError", sync_error.ToValue()); 57 details.Set("syncError", sync_error.ToValue());
58 HandleJsEvent(FROM_HERE, "onActionableError", 58 HandleJsEvent(FROM_HERE, "onActionableError", JsEventDetails(&details));
59 JsEventDetails(&details));
60 } 59 }
61 60
62 void JsSyncManagerObserver::OnProtocolEvent( 61 void JsSyncManagerObserver::OnProtocolEvent(const ProtocolEvent& event) {}
63 const ProtocolEvent& event) { }
64 62
65 void JsSyncManagerObserver::OnMigrationRequested(ModelTypeSet types) { } 63 void JsSyncManagerObserver::OnMigrationRequested(ModelTypeSet types) {}
66 64
67 void JsSyncManagerObserver::OnInitializationComplete( 65 void JsSyncManagerObserver::OnInitializationComplete(
68 const WeakHandle<JsBackend>& js_backend, 66 const WeakHandle<JsBackend>& js_backend,
69 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener, 67 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener,
70 bool success, syncer::ModelTypeSet restored_types) { 68 bool success,
69 syncer::ModelTypeSet restored_types) {
71 if (!event_handler_.IsInitialized()) { 70 if (!event_handler_.IsInitialized()) {
72 return; 71 return;
73 } 72 }
74 // Ignore the |js_backend| argument; it's not really convertible to 73 // Ignore the |js_backend| argument; it's not really convertible to
75 // JSON anyway. 74 // JSON anyway.
76 75
77 base::DictionaryValue details; 76 base::DictionaryValue details;
78 details.Set("restoredTypes", ModelTypeSetToValue(restored_types)); 77 details.Set("restoredTypes", ModelTypeSetToValue(restored_types));
79 78
80 HandleJsEvent(FROM_HERE, 79 HandleJsEvent(FROM_HERE, "onInitializationComplete",
81 "onInitializationComplete",
82 JsEventDetails(&details)); 80 JsEventDetails(&details));
83 } 81 }
84 82
85 void JsSyncManagerObserver::HandleJsEvent( 83 void JsSyncManagerObserver::HandleJsEvent(
86 const tracked_objects::Location& from_here, 84 const tracked_objects::Location& from_here,
87 const std::string& name, const JsEventDetails& details) { 85 const std::string& name,
86 const JsEventDetails& details) {
88 if (!event_handler_.IsInitialized()) { 87 if (!event_handler_.IsInitialized()) {
89 NOTREACHED(); 88 NOTREACHED();
90 return; 89 return;
91 } 90 }
92 event_handler_.Call(from_here, 91 event_handler_.Call(from_here, &JsEventHandler::HandleJsEvent, name, details);
93 &JsEventHandler::HandleJsEvent, name, details);
94 } 92 }
95 93
96 } // namespace syncer 94 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core_impl/js_sync_manager_observer.h ('k') | components/sync/core_impl/js_sync_manager_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698