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

Side by Side Diff: chrome/browser/component_updater/pnacl/pnacl_component_installer.h

Issue 18006003: Consistently use notifications from component updater w/ on-demand PNaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: callback.h Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_PNACL_PNACL_COMPONENT_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_ 6 #define CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/version.h" 14 #include "base/version.h"
15 #include "chrome/browser/component_updater/component_updater_service.h" 15 #include "chrome/browser/component_updater/component_updater_service.h"
16 #include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h" 16 #include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h"
17 #include "chrome/browser/component_updater/pnacl/pnacl_updater_observer.h" 17 #include "chrome/browser/component_updater/pnacl/pnacl_updater_observer.h"
18 18
19 class CommandLine; 19 class CommandLine;
20 20
(...skipping 19 matching lines...) Expand all
40 base::FilePath* installed_file) OVERRIDE; 40 base::FilePath* installed_file) OVERRIDE;
41 41
42 // Register a PNaCl component for the first time. 42 // Register a PNaCl component for the first time.
43 void RegisterPnaclComponent(ComponentUpdateService* cus, 43 void RegisterPnaclComponent(ComponentUpdateService* cus,
44 const CommandLine& command_line); 44 const CommandLine& command_line);
45 45
46 // Check the PNaCl version again and re-register with the component 46 // Check the PNaCl version again and re-register with the component
47 // updater service. 47 // updater service.
48 void ReRegisterPnacl(); 48 void ReRegisterPnacl();
49 49
50 CrxComponent GetCrxComponent();
51
50 // Return true if PNaCl installs are separated by user. 52 // Return true if PNaCl installs are separated by user.
51 bool per_user() const { return per_user_; } 53 bool per_user() const { return per_user_; }
52 54
53 // If per_user, function to call when profile is changed. 55 // If per_user, function to call when profile is changed.
54 void OnProfileChange(); 56 void OnProfileChange();
55 57
56 // Return true if PNaCl updates are disabled. 58 // Return true if PNaCl updates are disabled.
57 bool updates_disabled() const { return updates_disabled_; } 59 bool updates_disabled() const { return updates_disabled_; }
58 60
59 // Determine the base directory for storing each version of PNaCl. 61 // Determine the base directory for storing each version of PNaCl.
60 base::FilePath GetPnaclBaseDirectory(); 62 base::FilePath GetPnaclBaseDirectory();
61 63
62 base::Version current_version() const { return current_version_; } 64 base::Version current_version() const { return current_version_; }
63 65
64 void set_current_version(const base::Version& v) { current_version_ = v; } 66 void set_current_version(const base::Version& v) { current_version_ = v; }
65 67
66 ComponentUpdateService* cus() const { return cus_; } 68 ComponentUpdateService* cus() const { return cus_; }
67 69
68 typedef base::Callback<void(bool)> InstallCallback; 70 typedef base::Callback<void(bool)> InstallCallback;
69 void AddInstallCallback(const InstallCallback& cb);
70 71
71 void NotifyInstallError(); 72 // Ask the component updater service to do a first-install for PNaCl.
73 // The |installed| callback will be run with |true| on success,
74 // or run with |false| on an error. The callback is called on the UI thread.
75 void RequestFirstInstall(const InstallCallback& installed);
72 76
77 private:
78 friend class PnaclUpdaterObserver;
Sorin Jianu 2013/08/05 19:24:58 Since I am a n00b in Chrome dev I am not sure what
jvoung (off chromium) 2013/08/05 20:36:03 In general chrome code style is like google code s
79
80 // Called when a RequestFirstInstall completed successfully.
73 void NotifyInstallSuccess(); 81 void NotifyInstallSuccess();
74 82
75 private: 83 // Called when a RequestFirstInstall will not happen, or an error occurred.
76 // Cancel a particular callback after a timeout. 84 void NotifyInstallError();
77 void CancelCallback(int callback_num);
78
79 void NotifyAllWithResult(bool status);
80 85
81 bool per_user_; 86 bool per_user_;
82 bool updates_disabled_; 87 bool updates_disabled_;
83 scoped_ptr<PnaclProfileObserver> profile_observer_; 88 scoped_ptr<PnaclProfileObserver> profile_observer_;
84 base::FilePath current_profile_path_; 89 base::FilePath current_profile_path_;
85 base::Version current_version_; 90 base::Version current_version_;
86 ComponentUpdateService* cus_; 91 ComponentUpdateService* cus_;
87 // Counter to issue identifiers to each callback. 92 // The one callback to call when there is a RequestFirstInstall.
88 int callback_nums_; 93 InstallCallback install_callback_;
89 // List of callbacks to issue when an install completes successfully.
90 std::list<std::pair<InstallCallback, int> > install_callbacks_;
91 // Component updater service observer, to determine when an on-demand 94 // Component updater service observer, to determine when an on-demand
92 // install request failed. 95 // install request failed.
93 scoped_ptr<PnaclUpdaterObserver> updater_observer_; 96 scoped_ptr<PnaclUpdaterObserver> updater_observer_;
94 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller); 97 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller);
95 }; 98 };
96 99
97 // Returns true if this browser is compatible with the given Pnacl component
98 // manifest, with the version specified in the manifest in |version_out|.
99 bool CheckPnaclComponentManifest(const base::DictionaryValue& manifest,
100 base::Version* version_out);
101
102 // Ask the given component updater service to do a first-install for PNaCl.
103 // The |installed| callback will be run with |true| on success,
104 // or run with |false| on an error. The callback is called on the UI thread.
105 void RequestFirstInstall(ComponentUpdateService* cus,
106 PnaclComponentInstaller* pci,
107 const base::Callback<void(bool)>& installed);
108
109 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_ 100 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698