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

Side by Side Diff: chrome/browser/extensions/api/system_display/display_info_provider.h

Issue 23441032: [SystemInfo API] Rewrite DisplayInfoProvider without SystemInfoProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/lazy_instance.h"
11 #include "chrome/browser/extensions/api/system_info/system_info_provider.h"
12 #include "chrome/common/extensions/api/system_display.h" 11 #include "chrome/common/extensions/api/system_display.h"
13 12
14 namespace gfx { 13 namespace gfx {
15 class Display; 14 class Display;
16 } 15 }
17 16
18 namespace extensions { 17 namespace extensions {
19 18
20 typedef std::vector<linked_ptr< 19 typedef std::vector<linked_ptr<
21 api::system_display::DisplayUnitInfo> > DisplayInfo; 20 api::system_display::DisplayUnitInfo> > DisplayInfo;
22 21
23 class DisplayInfoProvider : public SystemInfoProvider { 22 class DisplayInfoProvider {
24 public: 23 public :
25 typedef base::Callback<void(bool success)>
26 RequestInfoCallback;
27 typedef base::Callback<void(bool success, const std::string& error)>
28 SetInfoCallback;
29
30 // Gets a DisplayInfoProvider instance.
31 static DisplayInfoProvider* Get(); 24 static DisplayInfoProvider* Get();
32 25
33 // Starts request for the display info, redirecting the request to a worker
34 // thread if needed (using SystemInfoProvider<DisplayInfo>::StartQuery()).
35 // The callback will be called asynchronously.
36 // The implementation is platform specific.
37 void RequestInfo(const RequestInfoCallback& callback);
38
39 // Updates the display parameters for a display with the provided id.
40 // The parameters are updated according to content of |info|. After the
41 // display is updated, callback is called with the success status, and error
42 // message. If the method succeeds, the error message is empty.
43 // The callback will be called asynchronously.
44 // This functionality is exposed only on ChromeOS.
45 virtual void SetInfo(
46 const std::string& display_id,
47 const api::system_display::DisplayProperties& info,
48 const SetInfoCallback& callback);
49
50 const DisplayInfo& display_info() const;
51
52 static void InitializeForTesting(scoped_refptr<DisplayInfoProvider> provider);
53
54 protected:
55 DisplayInfoProvider(); 26 DisplayInfoProvider();
56 virtual ~DisplayInfoProvider(); 27 virtual ~DisplayInfoProvider();
57 28
58 // The last information filled up by QueryInfo and is accessed on multiple 29 static void InitializeForTesting(DisplayInfoProvider* display_info_helper);
59 // threads, but the whole class is being guarded by SystemInfoProvider base 30
60 // class. 31 DisplayInfo GetAllDisplaysInfo();
61 // 32
62 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is 33 virtual bool SetInfo(const std::string& display_id,
63 // false and on the sequenced worker pool while |is_waiting_for_completion_| 34 const api::system_display::DisplayProperties& info,
64 // is true. 35 std::string* error);
65 DisplayInfo info_;
66 36
67 private: 37 private:
68 // Overriden from SystemInfoProvider.
69 // The implementation is platform specific.
70 virtual bool QueryInfo() OVERRIDE;
71
72 // Update the content of the |unit| obtained for |display| using 38 // Update the content of the |unit| obtained for |display| using
73 // platform specific method. 39 // platform specific method.
74 void UpdateDisplayUnitInfoForPlatform( 40 virtual void UpdateDisplayUnitInfoForPlatform(
75 const gfx::Display& display, 41 const gfx::Display& display,
76 extensions::api::system_display::DisplayUnitInfo* unit); 42 extensions::api::system_display::DisplayUnitInfo* unit);
77 43
78 static base::LazyInstance<scoped_refptr<DisplayInfoProvider> > provider_;
79
80 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider); 44 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider);
81 }; 45 };
82 46
83 } // namespace extensions 47 } // namespace extensions
84 48
85 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ 49 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698