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/js/sync_js_controller.h" | 5 #include "sync/js/sync_js_controller.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "sync/js/js_backend.h" | 8 #include "sync/js/js_backend.h" |
9 #include "sync/js/js_event_details.h" | 9 #include "sync/js/js_event_details.h" |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 FOR_EACH_OBSERVER(JsEventHandler, js_event_handlers_, | 66 FOR_EACH_OBSERVER(JsEventHandler, js_event_handlers_, |
67 HandleJsEvent(name, details)); | 67 HandleJsEvent(name, details)); |
68 } | 68 } |
69 | 69 |
70 void SyncJsController::UpdateBackendEventHandler() { | 70 void SyncJsController::UpdateBackendEventHandler() { |
71 if (js_backend_.IsInitialized()) { | 71 if (js_backend_.IsInitialized()) { |
72 // To avoid making the backend send useless events, we clear the | 72 // To avoid making the backend send useless events, we clear the |
73 // event handler we pass to it if we don't have any event | 73 // event handler we pass to it if we don't have any event |
74 // handlers. | 74 // handlers. |
75 WeakHandle<JsEventHandler> backend_event_handler = | 75 WeakHandle<JsEventHandler> backend_event_handler = |
76 (js_event_handlers_.size() > 0) ? | 76 js_event_handlers_.might_have_observers() ? |
77 MakeWeakHandle(AsWeakPtr()) : WeakHandle<SyncJsController>(); | 77 MakeWeakHandle(AsWeakPtr()) : WeakHandle<SyncJsController>(); |
78 js_backend_.Call(FROM_HERE, &JsBackend::SetJsEventHandler, | 78 js_backend_.Call(FROM_HERE, &JsBackend::SetJsEventHandler, |
79 backend_event_handler); | 79 backend_event_handler); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 } // namespace syncer | 83 } // namespace syncer |
OLD | NEW |