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