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

Unified 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: Use valid display id. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/system_display/display_info_provider.h
diff --git a/chrome/browser/extensions/api/system_display/display_info_provider.h b/chrome/browser/extensions/api/system_display/display_info_provider.h
index 65f94ebec437fbcc372b5835e4ebbe3a455cb8e8..50eec2e0d1484401959ee65922f0fbdbbac4f27c 100644
--- a/chrome/browser/extensions/api/system_display/display_info_provider.h
+++ b/chrome/browser/extensions/api/system_display/display_info_provider.h
@@ -6,9 +6,8 @@
#define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_
#include <string>
+#include <vector>
-#include "base/lazy_instance.h"
-#include "chrome/browser/extensions/api/system_info/system_info_provider.h"
#include "chrome/common/extensions/api/system_display.h"
namespace gfx {
@@ -20,63 +19,30 @@ namespace extensions {
typedef std::vector<linked_ptr<
api::system_display::DisplayUnitInfo> > DisplayInfo;
-class DisplayInfoProvider : public SystemInfoProvider {
- public:
- typedef base::Callback<void(bool success)>
- RequestInfoCallback;
- typedef base::Callback<void(bool success, const std::string& error)>
- SetInfoCallback;
-
- // Gets a DisplayInfoProvider instance.
+class DisplayInfoProvider {
+ public :
static DisplayInfoProvider* Get();
- // Starts request for the display info, redirecting the request to a worker
- // thread if needed (using SystemInfoProvider<DisplayInfo>::StartQuery()).
- // The callback will be called asynchronously.
- // The implementation is platform specific.
- void RequestInfo(const RequestInfoCallback& callback);
-
- // Updates the display parameters for a display with the provided id.
- // The parameters are updated according to content of |info|. After the
- // display is updated, callback is called with the success status, and error
- // message. If the method succeeds, the error message is empty.
- // The callback will be called asynchronously.
- // This functionality is exposed only on ChromeOS.
- virtual void SetInfo(
- const std::string& display_id,
- const api::system_display::DisplayProperties& info,
- const SetInfoCallback& callback);
-
- const DisplayInfo& display_info() const;
-
- static void InitializeForTesting(scoped_refptr<DisplayInfoProvider> provider);
-
- protected:
DisplayInfoProvider();
virtual ~DisplayInfoProvider();
- // The last information filled up by QueryInfo and is accessed on multiple
- // threads, but the whole class is being guarded by SystemInfoProvider base
- // class.
- //
- // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is
- // false and on the sequenced worker pool while |is_waiting_for_completion_|
- // is true.
- DisplayInfo info_;
+ // This is for tests that run in its own process (e.g. browser_tests).
+ // Using this in other tests (e.g. unit_tests) will result in DCHECK failure.
+ static void InitializeForTesting(DisplayInfoProvider* display_info_provider);
- private:
- // Overriden from SystemInfoProvider.
- // The implementation is platform specific.
- virtual bool QueryInfo() OVERRIDE;
+ DisplayInfo GetAllDisplaysInfo();
+
+ virtual bool SetInfo(const std::string& display_id,
+ const api::system_display::DisplayProperties& info,
+ std::string* error);
+ private:
// Update the content of the |unit| obtained for |display| using
// platform specific method.
- void UpdateDisplayUnitInfoForPlatform(
+ virtual void UpdateDisplayUnitInfoForPlatform(
const gfx::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit);
- static base::LazyInstance<scoped_refptr<DisplayInfoProvider> > provider_;
-
DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider);
};

Powered by Google App Engine
This is Rietveld 408576698