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

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: Update 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/system_display/display_info_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Works for browser tests, which runs its own process, this doesn't work for
oshima 2013/09/11 02:55:40 This is for tests that run in its own process (e.g
Haojian Wu 2013/09/11 03:09:16 Done. Updated.
59 // threads, but the whole class is being guarded by SystemInfoProvider base 30 // unit tests where multiple tests are run within one process.
60 // class. 31 static void InitializeForTesting(DisplayInfoProvider* display_info_helper);
61 // 32
62 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is 33 DisplayInfo GetAllDisplaysInfo();
63 // false and on the sequenced worker pool while |is_waiting_for_completion_| 34
64 // is true. 35 virtual bool SetInfo(const std::string& display_id,
65 DisplayInfo info_; 36 const api::system_display::DisplayProperties& info,
37 std::string* error);
66 38
67 private: 39 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 40 // Update the content of the |unit| obtained for |display| using
73 // platform specific method. 41 // platform specific method.
74 void UpdateDisplayUnitInfoForPlatform( 42 virtual void UpdateDisplayUnitInfoForPlatform(
75 const gfx::Display& display, 43 const gfx::Display& display,
76 extensions::api::system_display::DisplayUnitInfo* unit); 44 extensions::api::system_display::DisplayUnitInfo* unit);
77 45
78 static base::LazyInstance<scoped_refptr<DisplayInfoProvider> > provider_;
79
80 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider); 46 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider);
81 }; 47 };
82 48
83 } // namespace extensions 49 } // namespace extensions
84 50
85 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ 51 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/system_display/display_info_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698