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

Side by Side Diff: components/update_client/update_engine.h

Issue 1740333002: Allow fallback from https to http for component update checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_UPDATE_CLIENT_UPDATE_ENGINE_H_ 5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_ENGINE_H_
6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_ENGINE_H_ 6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_ENGINE_H_
7 7
8 #include <list> 8 #include <list>
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 bool GetUpdateState(const std::string& id, CrxUpdateItem* update_state); 56 bool GetUpdateState(const std::string& id, CrxUpdateItem* update_state);
57 57
58 void Update(bool is_foreground, 58 void Update(bool is_foreground,
59 const std::vector<std::string>& ids, 59 const std::vector<std::string>& ids,
60 const UpdateClient::CrxDataCallback& crx_data_callback, 60 const UpdateClient::CrxDataCallback& crx_data_callback,
61 const CompletionCallback& update_callback); 61 const CompletionCallback& update_callback);
62 62
63 private: 63 private:
64 void UpdateComplete(UpdateContext* update_context, int error); 64 void UpdateComplete(UpdateContext* update_context, int error);
65 65
66 // Returns true if the update engine rejects this update call because it
67 // occurs too soon.
68 bool IsThrottled(bool is_foreground) const;
69
66 base::ThreadChecker thread_checker_; 70 base::ThreadChecker thread_checker_;
67 71
68 scoped_refptr<Configurator> config_; 72 scoped_refptr<Configurator> config_;
69 73
70 UpdateChecker::Factory update_checker_factory_; 74 UpdateChecker::Factory update_checker_factory_;
71 CrxDownloader::Factory crx_downloader_factory_; 75 CrxDownloader::Factory crx_downloader_factory_;
72 76
73 // TODO(sorin): refactor as a ref counted class. 77 // TODO(sorin): refactor as a ref counted class.
74 PingManager* ping_manager_; // Not owned by this class. 78 PingManager* ping_manager_; // Not owned by this class.
75 79
76 // Called when CRX state changes occur. 80 // Called when CRX state changes occur.
77 const NotifyObserversCallback notify_observers_callback_; 81 const NotifyObserversCallback notify_observers_callback_;
78 82
79 // Contains the contexts associated with each update in progress. 83 // Contains the contexts associated with each update in progress.
80 std::set<UpdateContext*> update_contexts_; 84 std::set<UpdateContext*> update_contexts_;
81 85
86 // Implements a rate limiting mechanism for background update checks. Has the
87 // effect of rejecting the update call if the update call occurs before
88 // a certain time, which is negotiated with the server as part of the
89 // update protocol. See the comments for X-Retry-After header.
90 base::Time throttle_updates_until_;
91
82 DISALLOW_COPY_AND_ASSIGN(UpdateEngine); 92 DISALLOW_COPY_AND_ASSIGN(UpdateEngine);
83 }; 93 };
84 94
85 // TODO(sorin): consider making this a ref counted type. 95 // TODO(sorin): consider making this a ref counted type.
86 struct UpdateContext { 96 struct UpdateContext {
87 UpdateContext( 97 UpdateContext(
88 const scoped_refptr<Configurator>& config, 98 const scoped_refptr<Configurator>& config,
89 bool is_foreground, 99 bool is_foreground,
90 const std::vector<std::string>& ids, 100 const std::vector<std::string>& ids,
91 const UpdateClient::CrxDataCallback& crx_data_callback, 101 const UpdateClient::CrxDataCallback& crx_data_callback,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 138
129 PingManager* ping_manager; // Not owned by this class. 139 PingManager* ping_manager; // Not owned by this class.
130 140
131 scoped_ptr<Action> current_action; 141 scoped_ptr<Action> current_action;
132 142
133 // TODO(sorin): use a map instead of vector. 143 // TODO(sorin): use a map instead of vector.
134 std::vector<CrxUpdateItem*> update_items; 144 std::vector<CrxUpdateItem*> update_items;
135 145
136 // Contains the ids of the items to update. 146 // Contains the ids of the items to update.
137 std::queue<std::string> queue; 147 std::queue<std::string> queue;
148
149 // The time in seconds to wait until doing further update checks.
150 int retry_after_sec_;
138 }; 151 };
139 152
140 } // namespace update_client 153 } // namespace update_client
141 154
142 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_ENGINE_H_ 155 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_ENGINE_H_
OLDNEW
« no previous file with comments | « components/update_client/update_client_unittest.cc ('k') | components/update_client/update_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698