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

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

Issue 2888183003: Consolidate the update_client serialization code. (Closed)
Patch Set: wip Created 3 years, 7 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 | components/update_client/component.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_COMPONENT_H_ 5 #ifndef COMPONENTS_UPDATE_CLIENT_COMPONENT_H_
6 #define COMPONENTS_UPDATE_CLIENT_COMPONENT_H_ 6 #define COMPONENTS_UPDATE_CLIENT_COMPONENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 void UpdateCheckComplete() const; 57 void UpdateCheckComplete() const;
58 58
59 // Returns true if the component has reached a final state and no further 59 // Returns true if the component has reached a final state and no further
60 // handling and state transitions are possible. 60 // handling and state transitions are possible.
61 bool IsHandled() const { return state_->IsFinal(); } 61 bool IsHandled() const { return state_->IsFinal(); }
62 62
63 // Returns true if an update is available for this component, meaning that 63 // Returns true if an update is available for this component, meaning that
64 // the update server has return a response containing an update. 64 // the update server has return a response containing an update.
65 bool IsUpdateAvailable() const { return is_update_available_; } 65 bool IsUpdateAvailable() const { return is_update_available_; }
66 66
67 // Returns true if a ping must be sent back to the server. As a general rule, 67 /*
68 // a ping is sent only for server responses containing instructions to update. 68 // Returns true if a ping must be sent back to the server. As a general
69 bool CanPing() const { 69 rule,
70 return IsUpdateAvailable() || state() == ComponentState::kUninstalled; 70 // a ping is sent only for server responses containing instructions to
71 } 71 update. bool CanPing() const { return IsUpdateAvailable() || state() ==
72 72 ComponentState::kUninstalled;
73 }
74 */
73 base::TimeDelta GetUpdateDuration() const; 75 base::TimeDelta GetUpdateDuration() const;
74 76
75 ComponentState state() const { return state_->state(); } 77 ComponentState state() const { return state_->state(); }
76 78
77 std::string id() const { return id_; } 79 std::string id() const { return id_; }
78 80
79 const CrxComponent& crx_component() const { return crx_component_; } 81 const CrxComponent& crx_component() const { return crx_component_; }
80 void set_crx_component(const CrxComponent& crx_component) { 82 void set_crx_component(const CrxComponent& crx_component) {
81 crx_component_ = crx_component; 83 crx_component_ = crx_component;
82 } 84 }
(...skipping 19 matching lines...) Expand all
102 } 104 }
103 105
104 // Returns the time when processing of an update for this component has 106 // Returns the time when processing of an update for this component has
105 // begun, once the update has been discovered. Returns a null TimeTicks object 107 // begun, once the update has been discovered. Returns a null TimeTicks object
106 // if the handling of an update has not happened. 108 // if the handling of an update has not happened.
107 // base::TimeTicks update_begin() const { return update_begin_; } 109 // base::TimeTicks update_begin() const { return update_begin_; }
108 110
109 bool on_demand() const { return on_demand_; } 111 bool on_demand() const { return on_demand_; }
110 void set_on_demand(bool on_demand) { on_demand_ = on_demand; } 112 void set_on_demand(bool on_demand) { on_demand_ = on_demand; }
111 113
112 const std::vector<CrxDownloader::DownloadMetrics>& download_metrics() const { 114 const std::vector<std::string>& events() const { return events_; }
113 return download_metrics_;
114 }
115 115
116 const std::vector<GURL>& crx_diffurls() const { return crx_diffurls_; } 116 const std::vector<GURL>& crx_diffurls() const { return crx_diffurls_; }
117 117
118 bool diff_update_failed() const { return !!diff_error_code_; } 118 bool diff_update_failed() const { return !!diff_error_code_; }
119 119
120 int error_category() const { return error_category_; } 120 int error_category() const { return error_category_; }
121 int error_code() const { return error_code_; } 121 int error_code() const { return error_code_; }
122 int extra_code1() const { return extra_code1_; } 122 int extra_code1() const { return extra_code1_; }
123 int diff_error_category() const { return diff_error_category_; } 123 int diff_error_category() const { return diff_error_category_; }
124 int diff_error_code() const { return diff_error_code_; } 124 int diff_error_code() const { return diff_error_code_; }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // State overrides. 340 // State overrides.
341 void DoHandle() override; 341 void DoHandle() override;
342 342
343 DISALLOW_COPY_AND_ASSIGN(StateUninstalled); 343 DISALLOW_COPY_AND_ASSIGN(StateUninstalled);
344 }; 344 };
345 345
346 // Returns true is the update payload for this component can be downloaded 346 // Returns true is the update payload for this component can be downloaded
347 // by a downloader which can do bandwidth throttling on the client side. 347 // by a downloader which can do bandwidth throttling on the client side.
348 bool CanDoBackgroundDownload() const; 348 bool CanDoBackgroundDownload() const;
349 349
350 void AppendDownloadMetrics( 350 void AppendEvent(const std::string& event);
351 const std::vector<CrxDownloader::DownloadMetrics>& download_metrics);
352 351
353 // Changes the component state and notifies the caller of the |Handle| 352 // Changes the component state and notifies the caller of the |Handle|
354 // function that the handling of this component state is complete. 353 // function that the handling of this component state is complete.
355 void ChangeState(std::unique_ptr<State> next_state); 354 void ChangeState(std::unique_ptr<State> next_state);
356 355
357 // Notifies registered observers about changes in the state of the component. 356 // Notifies registered observers about changes in the state of the component.
358 void NotifyObservers(Events event) const; 357 void NotifyObservers(Events event) const;
359 358
360 base::ThreadChecker thread_checker_; 359 base::ThreadChecker thread_checker_;
361 360
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // the |extra_code1| usually contains a system error, but it can contain 403 // the |extra_code1| usually contains a system error, but it can contain
405 // any extended information that is relevant to either the category or the 404 // any extended information that is relevant to either the category or the
406 // error itself. 405 // error itself.
407 int error_category_ = 0; 406 int error_category_ = 0;
408 int error_code_ = 0; 407 int error_code_ = 0;
409 int extra_code1_ = 0; 408 int extra_code1_ = 0;
410 int diff_error_category_ = 0; 409 int diff_error_category_ = 0;
411 int diff_error_code_ = 0; 410 int diff_error_code_ = 0;
412 int diff_extra_code1_ = 0; 411 int diff_extra_code1_ = 0;
413 412
414 std::vector<CrxDownloader::DownloadMetrics> download_metrics_; 413 std::vector<std::string> events_;
415 414
416 CallbackHandleComplete callback_handle_complete_; 415 CallbackHandleComplete callback_handle_complete_;
417 std::unique_ptr<State> state_; 416 std::unique_ptr<State> state_;
418 const UpdateContext& update_context_; 417 const UpdateContext& update_context_;
419 418
420 base::Closure update_check_complete_; 419 base::Closure update_check_complete_;
421 420
422 DISALLOW_COPY_AND_ASSIGN(Component); 421 DISALLOW_COPY_AND_ASSIGN(Component);
423 }; 422 };
424 423
425 using IdToComponentPtrMap = std::map<std::string, std::unique_ptr<Component>>; 424 using IdToComponentPtrMap = std::map<std::string, std::unique_ptr<Component>>;
426 425
427 } // namespace update_client 426 } // namespace update_client
428 427
429 #endif // COMPONENTS_UPDATE_CLIENT_COMPONENT_H_ 428 #endif // COMPONENTS_UPDATE_CLIENT_COMPONENT_H_
OLDNEW
« no previous file with comments | « no previous file | components/update_client/component.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698