Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Side by Side Diff: chrome/browser/device_orientation/provider.h

Issue 2858049: Chromium plumbing for Device Orientation. (Closed)
Patch Set: Fixes after try bot runs Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 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_DEVICE_ORIENTATION_PROVIDER_H_
6 #define CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_
7
8 #include "base/logging.h"
9 #include "base/ref_counted.h"
10
11 namespace device_orientation {
12
13 class Orientation;
14
15 class Provider : public base::RefCounted<Provider> {
16 public:
17 class Observer {
18 public:
19 // Called when the orientation changes.
20 // An Observer must not synchronously call Provider::RemoveObserver
21 // or Provider::AddObserver when this is called.
22 virtual void OnOrientationUpdate(const Orientation& orientation) = 0;
23 };
24
25 // Returns a pointer to the singleton instance of this class.
26 // The caller should store the returned pointer in a scoped_refptr.
27 // The Provider instance is lazily constructed when GetInstance() is called,
28 // and destructed when the last scoped_refptr referring to it is destructed.
29 static Provider* GetInstance();
30
31 // Inject a mock Provider for testing. Only a weak pointer to the injected
32 // object will be held by Provider, i.e. it does not itself contribute to the
33 // injected object's reference count.
34 static void SetInstanceForTests(Provider* provider);
35
36 virtual void AddObserver(Observer* observer) {}
37 virtual void RemoveObserver(Observer* observer) {}
38
39 protected:
40 Provider() {}
41 virtual ~Provider() {
42 DCHECK(instance_ == this);
43 instance_ = NULL;
44 }
45
46 private:
47 friend class base::RefCounted<Provider>;
48 static Provider* instance_;
49
50 DISALLOW_COPY_AND_ASSIGN(Provider);
51 };
52
53 } // namespace device_orientation
54
55 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/device_orientation/orientation.h ('k') | chrome/browser/device_orientation/provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698