OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef COMPONENTS_SYNC_JS_JS_CONTROLLER_H_ | 5 #ifndef COMPONENTS_SYNC_JS_JS_CONTROLLER_H_ |
6 #define COMPONENTS_SYNC_JS_JS_CONTROLLER_H_ | 6 #define COMPONENTS_SYNC_JS_JS_CONTROLLER_H_ |
7 | 7 |
8 // See README.js for design comments. | 8 // See README.js for design comments. |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "components/sync/base/sync_export.h" | |
13 | |
14 namespace syncer { | 12 namespace syncer { |
15 | 13 |
16 class JsEventHandler; | 14 class JsEventHandler; |
17 template <typename T> | 15 template <typename T> |
18 class WeakHandle; | 16 class WeakHandle; |
19 | 17 |
20 // An interface for objects that JsEventHandlers directly interact | 18 // An interface for objects that JsEventHandlers directly interact |
21 // with. JsEventHandlers can add themselves to receive events and | 19 // with. JsEventHandlers can add themselves to receive events and |
22 // also send messages which will eventually reach the backend. | 20 // also send messages which will eventually reach the backend. |
23 class SYNC_EXPORT JsController { | 21 class JsController { |
24 public: | 22 public: |
25 // Adds an event handler which will start receiving JS events (not | 23 // Adds an event handler which will start receiving JS events (not |
26 // immediately, so this can be called in the handler's constructor). | 24 // immediately, so this can be called in the handler's constructor). |
27 // Multiple event handlers are supported, but each event handler | 25 // Multiple event handlers are supported, but each event handler |
28 // must be added at most once. | 26 // must be added at most once. |
29 // | 27 // |
30 // Ideally, we'd take WeakPtrs, but we need the raw pointer values | 28 // Ideally, we'd take WeakPtrs, but we need the raw pointer values |
31 // to be able to look them up for removal. | 29 // to be able to look them up for removal. |
32 virtual void AddJsEventHandler(JsEventHandler* event_handler) = 0; | 30 virtual void AddJsEventHandler(JsEventHandler* event_handler) = 0; |
33 | 31 |
34 // Removes the given event handler if it has been added. It will | 32 // Removes the given event handler if it has been added. It will |
35 // immediately stop receiving any JS events. | 33 // immediately stop receiving any JS events. |
36 virtual void RemoveJsEventHandler(JsEventHandler* event_handler) = 0; | 34 virtual void RemoveJsEventHandler(JsEventHandler* event_handler) = 0; |
37 | 35 |
38 protected: | 36 protected: |
39 virtual ~JsController() {} | 37 virtual ~JsController() {} |
40 }; | 38 }; |
41 | 39 |
42 } // namespace syncer | 40 } // namespace syncer |
43 | 41 |
44 #endif // COMPONENTS_SYNC_JS_JS_CONTROLLER_H_ | 42 #endif // COMPONENTS_SYNC_JS_JS_CONTROLLER_H_ |
OLD | NEW |