summaryrefslogtreecommitdiffstats
path: root/chrome/browser/device_orientation/dispatcher_host.h
blob: d30e8201aed65ad055fa8d47fb1365a4c2222f8c (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
45
46
// Copyright (c) 2010 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_DEVICE_ORIENTATION_DISPATCHER_HOST_H_
#define CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_

#include <map>

#include "base/ref_counted.h"
#include "chrome/browser/device_orientation/provider.h"

namespace IPC { class Message; }

namespace device_orientation {

class Orientation;

class DispatcherHost : public base::RefCounted<DispatcherHost> {
 public:
  explicit DispatcherHost(int process_id);
  bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok);

 private:
  virtual ~DispatcherHost();
  friend class base::RefCounted<DispatcherHost>;

  void OnStartUpdating(int render_view_id);
  void OnStopUpdating(int render_view_id);

  // Helper class that observes a Provider and forwards updates to a RenderView.
  class ObserverDelegate;

  int process_id_;

  // map from render_view_id to ObserverDelegate.
  std::map<int, scoped_refptr<ObserverDelegate> > observers_map_;

  scoped_refptr<Provider> provider_;

  DISALLOW_COPY_AND_ASSIGN(DispatcherHost);
};

}  // namespace device_orientation

#endif  // CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_