Home | History | Annotate | Download | only in sync
      1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_JS_BACKEND_H_
      6 #define CHROME_BROWSER_SYNC_JS_BACKEND_H_
      7 #pragma once
      8 
      9 // See README.js for design comments.
     10 
     11 #include <string>
     12 
     13 namespace browser_sync {
     14 
     15 class JsArgList;
     16 class JsEventHandler;
     17 class JsEventRouter;
     18 
     19 class JsBackend {
     20  public:
     21   // Sets the JS event router to which all backend events will be
     22   // sent.
     23   virtual void SetParentJsEventRouter(JsEventRouter* router) = 0;
     24 
     25   // Removes any existing JS event router.
     26   virtual void RemoveParentJsEventRouter() = 0;
     27 
     28   // Gets the crurent JS event router, or NULL if there is none.  Used
     29   // for testing.
     30   virtual const JsEventRouter* GetParentJsEventRouter() const = 0;
     31 
     32   // Processes the given message.  All reply events are sent to the
     33   // parent JS event router (if set).
     34   virtual void ProcessMessage(
     35       const std::string& name, const JsArgList& args,
     36       const JsEventHandler* sender) = 0;
     37 
     38  protected:
     39   virtual ~JsBackend() {}
     40 };
     41 
     42 }  // namespace browser_sync
     43 
     44 #endif  // CHROME_BROWSER_SYNC_JS_BACKEND_H_
     45