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

Side by Side Diff: components/component_updater/component_updater_service.h

Issue 2154773002: Implement Just-In-Time Flash updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Through #27 + lint/format + offline comments Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 5 #ifndef COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/version.h" 17 #include "base/version.h"
18 #include "components/update_client/update_client.h" 18 #include "components/update_client/update_client.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 class ComponentsUI; 21 class ComponentsUI;
22 class PluginObserver;
22 class SupervisedUserWhitelistService; 23 class SupervisedUserWhitelistService;
23 24
24 namespace base { 25 namespace base {
25 class DictionaryValue; 26 class DictionaryValue;
26 class FilePath; 27 class FilePath;
27 class SequencedTaskRunner; 28 class SequencedTaskRunner;
28 } 29 }
29 30
30 namespace content { 31 namespace content {
31 class ResourceThrottle; 32 class ResourceThrottle;
(...skipping 12 matching lines...) Expand all
44 } 45 }
45 46
46 namespace component_updater { 47 namespace component_updater {
47 48
48 class OnDemandUpdater; 49 class OnDemandUpdater;
49 50
50 using Configurator = update_client::Configurator; 51 using Configurator = update_client::Configurator;
51 using CrxComponent = update_client::CrxComponent; 52 using CrxComponent = update_client::CrxComponent;
52 using CrxUpdateItem = update_client::CrxUpdateItem; 53 using CrxUpdateItem = update_client::CrxUpdateItem;
53 54
55 struct ComponentInfo {
56 ComponentInfo();
57 ~ComponentInfo();
58
59 std::string id;
60 base::string16 name;
61 };
62
54 // The component update service is in charge of installing or upgrading 63 // The component update service is in charge of installing or upgrading
55 // select parts of chrome. Each part is called a component and managed by 64 // select parts of chrome. Each part is called a component and managed by
56 // instances of CrxComponent registered using RegisterComponent(). On the 65 // instances of CrxComponent registered using RegisterComponent(). On the
57 // server, each component is packaged as a CRX which is the same format used 66 // server, each component is packaged as a CRX which is the same format used
58 // to package extensions. To the update service each component is identified 67 // to package extensions. To the update service each component is identified
59 // by its public key hash (CrxComponent::pk_hash). If there is an update 68 // by its public key hash (CrxComponent::pk_hash). If there is an update
60 // available and its version is bigger than (CrxComponent::version), it will 69 // available and its version is bigger than (CrxComponent::version), it will
61 // be downloaded, verified and unpacked. Then component-specific installer 70 // be downloaded, verified and unpacked. Then component-specific installer
62 // ComponentInstaller::Install (of CrxComponent::installer) will be called. 71 // ComponentInstaller::Install (of CrxComponent::installer) will be called.
63 // 72 //
(...skipping 25 matching lines...) Expand all
89 // existing versions of the component from disk. Returns true if the 98 // existing versions of the component from disk. Returns true if the
90 // uninstall has completed successfully and the component files have been 99 // uninstall has completed successfully and the component files have been
91 // removed, or if the uninstalled has been deferred because the component 100 // removed, or if the uninstalled has been deferred because the component
92 // is being updated. Returns false if the component id is not known or the 101 // is being updated. Returns false if the component id is not known or the
93 /// uninstall encountered an error. 102 /// uninstall encountered an error.
94 virtual bool UnregisterComponent(const std::string& id) = 0; 103 virtual bool UnregisterComponent(const std::string& id) = 0;
95 104
96 // Returns a list of registered components. 105 // Returns a list of registered components.
97 virtual std::vector<std::string> GetComponentIDs() const = 0; 106 virtual std::vector<std::string> GetComponentIDs() const = 0;
98 107
108 // Returns true and fills the members of |info| if there is a registered
109 // component that implements a handler for the specified |mime_type|; else
110 // returns false and does not mutate the members of |info|. If multiple
111 // such components exist, returns information for the one that was most
112 // recently registered.
113 virtual bool GetComponentForMimeType(const std::string& mime_type,
114 ComponentInfo* info) const = 0;
Sorin Jianu 2016/07/28 21:04:05 Another idea for this would be to return by value
waffles 2016/07/28 23:05:52 Done.
115
99 // Returns an interface for on-demand updates. On-demand updates are 116 // Returns an interface for on-demand updates. On-demand updates are
100 // proactively triggered outside the normal component update service schedule. 117 // proactively triggered outside the normal component update service schedule.
101 virtual OnDemandUpdater& GetOnDemandUpdater() = 0; 118 virtual OnDemandUpdater& GetOnDemandUpdater() = 0;
102 119
103 // This method is used to trigger an on-demand update for component |id|. 120 // This method is used to trigger an on-demand update for component |id|.
104 // This can be used when loading a resource that depends on this component. 121 // This can be used when loading a resource that depends on this component.
105 // 122 //
106 // |callback| is called on the main thread once the on-demand update is 123 // |callback| is called on the main thread once the on-demand update is
107 // complete, regardless of success. |callback| may be called immediately 124 // complete, regardless of success. |callback| may be called immediately
108 // within the method body. 125 // within the method body.
(...skipping 24 matching lines...) Expand all
133 using ServiceObserver = ComponentUpdateService::Observer; 150 using ServiceObserver = ComponentUpdateService::Observer;
134 151
135 class OnDemandUpdater { 152 class OnDemandUpdater {
136 public: 153 public:
137 virtual ~OnDemandUpdater() {} 154 virtual ~OnDemandUpdater() {}
138 155
139 private: 156 private:
140 friend class OnDemandTester; 157 friend class OnDemandTester;
141 friend class SupervisedUserWhitelistInstaller; 158 friend class SupervisedUserWhitelistInstaller;
142 friend class ::ComponentsUI; 159 friend class ::ComponentsUI;
160 friend class ::PluginObserver;
143 161
144 // Triggers an update check for a component. |id| is a value 162 // Triggers an update check for a component. |id| is a value
145 // returned by GetCrxComponentID(). If an update for this component is already 163 // returned by GetCrxComponentID(). If an update for this component is already
146 // in progress, the function returns |kInProgress|. If an update is available, 164 // in progress, the function returns |kInProgress|. If an update is available,
147 // the update will be applied. The caller can subscribe to component update 165 // the update will be applied. The caller can subscribe to component update
148 // service notifications to get an indication about the outcome of the 166 // service notifications to get an indication about the outcome of the
149 // on-demand update. The function does not implement any cooldown interval. 167 // on-demand update. The function does not implement any cooldown interval.
150 // TODO(sorin): improve this API so that the result of this non-blocking 168 // TODO(sorin): improve this API so that the result of this non-blocking
151 // call is provided by a callback. 169 // call is provided by a callback.
152 virtual bool OnDemandUpdate(const std::string& id) = 0; 170 virtual bool OnDemandUpdate(const std::string& id) = 0;
153 }; 171 };
154 172
155 // Creates the component updater. 173 // Creates the component updater.
156 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( 174 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory(
157 const scoped_refptr<Configurator>& config); 175 const scoped_refptr<Configurator>& config);
158 176
159 } // namespace component_updater 177 } // namespace component_updater
160 178
161 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 179 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698