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

Side by Side Diff: chrome/browser/component_updater/default_component_installer.h

Issue 385013002: Componentize component_updater: Replace content::BrowserThread usage with task runners (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ 6 #define CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread_checker.h"
13 #include "base/version.h" 15 #include "base/version.h"
14 #include "chrome/browser/component_updater/component_updater_service.h" 16 #include "chrome/browser/component_updater/component_updater_service.h"
15 17
16 namespace base { 18 namespace base {
17 class DictionaryValue; 19 class DictionaryValue;
18 class FilePath; 20 class FilePath;
21 class SequencedTaskRunner;
22 class SingleThreadTaskRunner;
19 } // namespace base 23 } // namespace base
20 24
21 namespace component_updater { 25 namespace component_updater {
22 26
23 // Components should use a DefaultComponentInstaller by defining a class that 27 // Components should use a DefaultComponentInstaller by defining a class that
24 // implements the members of ComponentInstallerTraits, and then registering a 28 // implements the members of ComponentInstallerTraits, and then registering a
25 // DefaultComponentInstaller that has been constructed with an instance of that 29 // DefaultComponentInstaller that has been constructed with an instance of that
26 // class. 30 // class.
27 class ComponentInstallerTraits { 31 class ComponentInstallerTraits {
28 public: 32 public:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 73
70 // Returns the human-readable name of the component. 74 // Returns the human-readable name of the component.
71 virtual std::string GetName() const = 0; 75 virtual std::string GetName() const = 0;
72 }; 76 };
73 77
74 // A DefaultComponentInstaller is intended to be final, and not derived from. 78 // A DefaultComponentInstaller is intended to be final, and not derived from.
75 // Customization must be provided by passing a ComponentInstallerTraits object 79 // Customization must be provided by passing a ComponentInstallerTraits object
76 // to the constructor. 80 // to the constructor.
77 class DefaultComponentInstaller : public ComponentInstaller { 81 class DefaultComponentInstaller : public ComponentInstaller {
78 public: 82 public:
79 explicit DefaultComponentInstaller( 83 DefaultComponentInstaller(
80 scoped_ptr<ComponentInstallerTraits> installer_traits); 84 scoped_ptr<ComponentInstallerTraits> installer_traits,
85 scoped_refptr<base::SequencedTaskRunner> task_runner);
81 86
82 // Registers the component for update checks and installs. 87 // Registers the component for update checks and installs.
83 void Register(ComponentUpdateService* cus); 88 void Register(ComponentUpdateService* cus);
84 89
85 // Overridden from ComponentInstaller: 90 // Overridden from ComponentInstaller:
86 virtual void OnUpdateError(int error) OVERRIDE; 91 virtual void OnUpdateError(int error) OVERRIDE;
87 virtual bool Install(const base::DictionaryValue& manifest, 92 virtual bool Install(const base::DictionaryValue& manifest,
88 const base::FilePath& unpack_path) OVERRIDE; 93 const base::FilePath& unpack_path) OVERRIDE;
89 virtual bool GetInstalledFile(const std::string& file, 94 virtual bool GetInstalledFile(const std::string& file,
90 base::FilePath* installed_file) OVERRIDE; 95 base::FilePath* installed_file) OVERRIDE;
91 96
92 virtual ~DefaultComponentInstaller(); 97 virtual ~DefaultComponentInstaller();
93 98
94 private: 99 private:
95 base::FilePath GetInstallDirectory(); 100 base::FilePath GetInstallDirectory();
96 bool InstallHelper(const base::DictionaryValue& manifest, 101 bool InstallHelper(const base::DictionaryValue& manifest,
97 const base::FilePath& unpack_path, 102 const base::FilePath& unpack_path,
98 const base::FilePath& install_path); 103 const base::FilePath& install_path);
99 void StartRegistration(ComponentUpdateService* cus); 104 void StartRegistration(ComponentUpdateService* cus);
100 void FinishRegistration(ComponentUpdateService* cus); 105 void FinishRegistration(ComponentUpdateService* cus);
101 106
102 base::Version current_version_; 107 base::Version current_version_;
103 std::string current_fingerprint_; 108 std::string current_fingerprint_;
104 scoped_ptr<base::DictionaryValue> current_manifest_; 109 scoped_ptr<base::DictionaryValue> current_manifest_;
105 scoped_ptr<ComponentInstallerTraits> installer_traits_; 110 scoped_ptr<ComponentInstallerTraits> installer_traits_;
111 scoped_refptr<base::SequencedTaskRunner> task_runner_;
112
113 // Used to post responses back to the main thread. Initialized on the main
114 // loop but accessed from the task runner.
115 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
116
117 base::ThreadChecker thread_checker_;
106 118
107 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); 119 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller);
108 }; 120 };
109 121
110 } // namespace component_updater 122 } // namespace component_updater
111 123
112 #endif // CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ 124 #endif // CHROME_BROWSER_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698