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

Unified Diff: components/quirks_client/quirks_client_manager.h

Issue 1528963002: Quirks Client for downloading and providing display profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First round of review fixes, separate QCManager into separate file Created 4 years, 11 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: components/quirks_client/quirks_client_manager.h
diff --git a/components/quirks_client/quirks_client_manager.h b/components/quirks_client/quirks_client_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..19a316552954a87713f7d37e1f0bf8cb5a202843
--- /dev/null
+++ b/components/quirks_client/quirks_client_manager.h
@@ -0,0 +1,83 @@
+// Copyright 2016 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 COMPONENTS_QUIRKS_CLIENT_QUIRKS_CLIENT_MANAGER_H_
+#define COMPONENTS_QUIRKS_CLIENT_QUIRKS_CLIENT_MANAGER_H_
+
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "components/quirks_client/quirks_client.h"
+
+class PrefRegistrySimple;
+class PrefService;
+
+namespace base {
+class SequencedWorkerPool;
+class MessageLoopForUI;
+}
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace quirks_client {
+
+// Handles needed components from browser (local preferences, url context
+// getter, message loops).
+class QUIRKS_CLIENT_EXPORT QuirksClientManager {
+ public:
+ // Delegate class, so implementation can access browser functionality.
+ class Delegate {
+ public:
+ virtual ~Delegate() {};
stevenjb 2016/02/02 23:45:51 = default
Greg Levin 2016/02/09 18:56:38 Done.
+ virtual std::string GetApiKey() const = 0;
+ virtual base::FilePath GetDisplayProfileDirectory() const = 0;
+ virtual int GetDaysSinceOobe() const = 0;
stevenjb 2016/02/02 23:45:52 private: DISALLOW_ASSIGN
Greg Levin 2016/02/09 18:56:38 Done. What are the pros/cons of putting DISALLOW_
+ };
+
+ QuirksClientManager(Delegate* delegate,
+ base::MessageLoopForUI* message_loop_ui,
+ base::SequencedWorkerPool* blocking_pool,
+ PrefService* local_state,
+ net::URLRequestContextGetter* url_context_getter);
+ virtual ~QuirksClientManager();
+
+ static void Initialize(QuirksClientManager* manager);
+ static void Shutdown();
+ static QuirksClientManager* Get();
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ void RunClient(int64_t product_id,
+ QuirksClient::DownloadFinishedCallback* on_download_finished);
+
+ base::Time GetLastServerCheck(int64_t product_id);
+ void SetLastServerCheck(int64_t product_id, const base::Time& last_check);
+ void RecordReasonUmaStat(QuirksClient::RequestReason reason);
+ void RecordFileFoundUmaStat(bool success);
+
+ Delegate* delegate() { return delegate_; }
+ base::SequencedWorkerPool* blocking_pool() { return blocking_pool_; }
+ net::URLRequestContextGetter* url_context_getter() {
+ return url_context_getter_.get();
+ }
+
+ // Check that ui thread and message loop are ready.
+ bool ValidateOnUiThread();
+
+ private:
+ // browser/ui thread components needed for client.
+ Delegate* delegate_; // Impl runs from browser.
+ base::MessageLoopForUI* message_loop_ui_; // To run QC on ui thread.
+ base::SequencedWorkerPool* blocking_pool_; // For url getter and file io.
+ PrefService* local_state_; // For local prefs.
+ bool is_new_device_; // Is within 30 days of OOBE?
+ // For URLFetcher.
+ scoped_refptr<net::URLRequestContextGetter> url_context_getter_;
+
+ DISALLOW_COPY_AND_ASSIGN(QuirksClientManager);
+};
+
+} // namespace chromeos
+
+#endif // COMPONENTS_QUIRKS_CLIENT_QUIRKS_CLIENT_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698