summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/js_backend.h
blob: 6d5ec92ba5ba714982afd49fc66b10224bd66b52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_JS_BACKEND_H_
#define CHROME_BROWSER_SYNC_JS_BACKEND_H_
#pragma once

// See README.js for design comments.

#include <string>

namespace browser_sync {

class JsArgList;
class JsEventHandler;
class JsEventRouter;

class JsBackend {
 public:
  // Sets the JS event router to which all backend events will be
  // sent.
  virtual void SetParentJsEventRouter(JsEventRouter* router) = 0;

  // Removes any existing JS event router.
  virtual void RemoveParentJsEventRouter() = 0;

  // Gets the crurent JS event router, or NULL if there is none.  Used
  // for testing.
  virtual const JsEventRouter* GetParentJsEventRouter() const = 0;

  // Processes the given message.  All reply events are sent to the
  // parent JS event router (if set).
  virtual void ProcessMessage(
      const std::string& name, const JsArgList& args,
      const JsEventHandler* sender) = 0;

 protected:
  virtual ~JsBackend() {}
};

}  // namespace browser_sync

#endif  // CHROME_BROWSER_SYNC_JS_BACKEND_H_