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

Side by Side Diff: components/sync/js/sync_js_controller.cc

Issue 2424673002: Remove usage of FOR_EACH_OBSERVER macro in components/sync (Closed)
Patch Set: blank line before return Created 4 years, 2 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 "components/sync/js/sync_js_controller.h" 5 #include "components/sync/js/sync_js_controller.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "components/sync/js/js_backend.h" 8 #include "components/sync/js/js_backend.h"
9 #include "components/sync/js/js_event_details.h" 9 #include "components/sync/js/js_event_details.h"
10 10
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 28
29 void SyncJsController::AttachJsBackend( 29 void SyncJsController::AttachJsBackend(
30 const WeakHandle<JsBackend>& js_backend) { 30 const WeakHandle<JsBackend>& js_backend) {
31 js_backend_ = js_backend; 31 js_backend_ = js_backend;
32 UpdateBackendEventHandler(); 32 UpdateBackendEventHandler();
33 } 33 }
34 34
35 void SyncJsController::HandleJsEvent(const std::string& name, 35 void SyncJsController::HandleJsEvent(const std::string& name,
36 const JsEventDetails& details) { 36 const JsEventDetails& details) {
37 FOR_EACH_OBSERVER(JsEventHandler, js_event_handlers_, 37 for (auto& observer : js_event_handlers_)
38 HandleJsEvent(name, details)); 38 observer.HandleJsEvent(name, details);
39 } 39 }
40 40
41 void SyncJsController::UpdateBackendEventHandler() { 41 void SyncJsController::UpdateBackendEventHandler() {
42 if (js_backend_.IsInitialized()) { 42 if (js_backend_.IsInitialized()) {
43 // To avoid making the backend send useless events, we clear the 43 // To avoid making the backend send useless events, we clear the
44 // event handler we pass to it if we don't have any event 44 // event handler we pass to it if we don't have any event
45 // handlers. 45 // handlers.
46 WeakHandle<JsEventHandler> backend_event_handler = 46 WeakHandle<JsEventHandler> backend_event_handler =
47 js_event_handlers_.might_have_observers() 47 js_event_handlers_.might_have_observers()
48 ? MakeWeakHandle(AsWeakPtr()) 48 ? MakeWeakHandle(AsWeakPtr())
49 : WeakHandle<SyncJsController>(); 49 : WeakHandle<SyncJsController>();
50 js_backend_.Call(FROM_HERE, &JsBackend::SetJsEventHandler, 50 js_backend_.Call(FROM_HERE, &JsBackend::SetJsEventHandler,
51 backend_event_handler); 51 backend_event_handler);
52 } 52 }
53 } 53 }
54 54
55 } // namespace syncer 55 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/sync_scheduler_impl.cc ('k') | components/sync/test/fake_server/fake_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698