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

Side by Side Diff: components/quirks/quirks_client.h

Issue 2765703003: Include display names in Quirks URL (Closed)
Patch Set: Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_QUIRKS_QUIRKS_CLIENT_H_ 5 #ifndef COMPONENTS_QUIRKS_QUIRKS_CLIENT_H_
6 #define COMPONENTS_QUIRKS_QUIRKS_CLIENT_H_ 6 #define COMPONENTS_QUIRKS_QUIRKS_CLIENT_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "net/base/backoff_entry.h" 14 #include "net/base/backoff_entry.h"
15 #include "net/url_request/url_fetcher_delegate.h" 15 #include "net/url_request/url_fetcher_delegate.h"
16 16
17 namespace quirks { 17 namespace quirks {
18 18
19 class QuirksManager; 19 class QuirksManager;
20 20
21 // See declaration in quirks_manager.h. 21 // See declaration in quirks_manager.h.
22 using RequestFinishedCallback = 22 using RequestFinishedCallback =
23 base::Callback<void(const base::FilePath&, bool)>; 23 base::Callback<void(const base::FilePath&, bool)>;
24 24
25 // Handles downloading icc and other display data files from Quirks Server. 25 // Handles downloading icc and other display data files from Quirks Server.
26 class QuirksClient : public net::URLFetcherDelegate { 26 class QuirksClient : public net::URLFetcherDelegate {
27 public: 27 public:
28 QuirksClient(int64_t product_id, 28 QuirksClient(int64_t product_id,
29 const std::string& display_name,
29 const RequestFinishedCallback& on_request_finished, 30 const RequestFinishedCallback& on_request_finished,
30 QuirksManager* manager); 31 QuirksManager* manager);
31 ~QuirksClient() override; 32 ~QuirksClient() override;
32 33
33 void StartDownload(); 34 void StartDownload();
34 35
35 int64_t product_id() const { return product_id_; } 36 int64_t product_id() const { return product_id_; }
36 37
37 private: 38 private:
38 // net::URLFetcherDelegate: 39 // net::URLFetcherDelegate:
39 void OnURLFetchComplete(const net::URLFetcher* source) override; 40 void OnURLFetchComplete(const net::URLFetcher* source) override;
40 41
41 // Send callback and tell manager to delete |this|. 42 // Send callback and tell manager to delete |this|.
42 void Shutdown(bool success); 43 void Shutdown(bool success);
43 44
44 // Schedules a retry. 45 // Schedules a retry.
45 void Retry(); 46 void Retry();
46 47
47 // Translates json with base64-encoded data (|result|) into raw |data|. 48 // Translates json with base64-encoded data (|result|) into raw |data|.
48 bool ParseResult(const std::string& result, std::string* data); 49 bool ParseResult(const std::string& result, std::string* data);
49 50
50 // ID of display to request from Quirks Server. 51 // ID of display to request from Quirks Server.
51 const int64_t product_id_; 52 const int64_t product_id_;
52 53
54 // Human-readable name to send to Quirks Server.
55 const std::string display_name_;
56
53 // Callback supplied by caller. 57 // Callback supplied by caller.
54 const RequestFinishedCallback on_request_finished_; 58 const RequestFinishedCallback on_request_finished_;
55 59
56 // Weak pointer owned by manager, guaranteed to outlive this client object. 60 // Weak pointer owned by manager, guaranteed to outlive this client object.
57 QuirksManager* manager_; 61 QuirksManager* manager_;
58 62
59 // Full path to icc file. 63 // Full path to icc file.
60 const base::FilePath icc_path_; 64 const base::FilePath icc_path_;
61 65
62 // The class is expected to run on UI thread. 66 // The class is expected to run on UI thread.
(...skipping 10 matching lines...) Expand all
73 77
74 // Factory for callbacks. 78 // Factory for callbacks.
75 base::WeakPtrFactory<QuirksClient> weak_ptr_factory_; 79 base::WeakPtrFactory<QuirksClient> weak_ptr_factory_;
76 80
77 DISALLOW_COPY_AND_ASSIGN(QuirksClient); 81 DISALLOW_COPY_AND_ASSIGN(QuirksClient);
78 }; 82 };
79 83
80 } // namespace quirks 84 } // namespace quirks
81 85
82 #endif // COMPONENTS_QUIRKS_QUIRKS_CLIENT_H_ 86 #endif // COMPONENTS_QUIRKS_QUIRKS_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/device_quirks_policy_browsertest.cc ('k') | components/quirks/quirks_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698