OLD | NEW |
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> |
| 9 |
| 10 #include "base/callback_forward.h" |
8 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
10 #include "base/version.h" | 13 #include "base/version.h" |
11 #include "chrome/browser/component_updater/component_updater_service.h" | 14 #include "chrome/browser/component_updater/component_updater_service.h" |
12 #include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h" | 15 #include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h" |
| 16 #include "chrome/browser/component_updater/pnacl/pnacl_updater_observer.h" |
13 | 17 |
14 class CommandLine; | 18 class CommandLine; |
15 | 19 |
16 namespace base { | 20 namespace base { |
17 class DictionaryValue; | 21 class DictionaryValue; |
18 } | 22 } |
19 | 23 |
20 // Component installer responsible for Portable Native Client files. | 24 // Component installer responsible for Portable Native Client files. |
21 // Files can be installed to a shared location, or be installed to | 25 // Files can be installed to a shared location, or be installed to |
22 // a per-user location. | 26 // a per-user location. |
(...skipping 23 matching lines...) Expand all Loading... |
46 | 50 |
47 // Determine the base directory for storing each version of PNaCl. | 51 // Determine the base directory for storing each version of PNaCl. |
48 base::FilePath GetPnaclBaseDirectory(); | 52 base::FilePath GetPnaclBaseDirectory(); |
49 | 53 |
50 base::Version current_version() const { return current_version_; } | 54 base::Version current_version() const { return current_version_; } |
51 | 55 |
52 void set_current_version(const base::Version& v) { current_version_ = v; } | 56 void set_current_version(const base::Version& v) { current_version_ = v; } |
53 | 57 |
54 ComponentUpdateService* cus() const { return cus_; } | 58 ComponentUpdateService* cus() const { return cus_; } |
55 | 59 |
| 60 typedef base::Callback<void(bool)> InstallCallback; |
| 61 void AddInstallCallback(const InstallCallback& cb); |
| 62 |
| 63 void NotifyInstallError(); |
| 64 |
| 65 void NotifyInstallSuccess(); |
| 66 |
56 private: | 67 private: |
| 68 // Cancel a particular callback after a timeout. |
| 69 void CancelCallback(int callback_num); |
| 70 |
| 71 void NotifyAllWithResult(bool status); |
| 72 |
57 bool per_user_; | 73 bool per_user_; |
58 scoped_ptr<PnaclProfileObserver> profile_observer_; | 74 scoped_ptr<PnaclProfileObserver> profile_observer_; |
59 base::FilePath current_profile_path_; | 75 base::FilePath current_profile_path_; |
60 base::Version current_version_; | 76 base::Version current_version_; |
61 ComponentUpdateService* cus_; | 77 ComponentUpdateService* cus_; |
| 78 // Counter to issue identifiers to each callback. |
| 79 int callback_nums_; |
| 80 // List of callbacks to issue when an install completes successfully. |
| 81 std::list<std::pair<InstallCallback, int> > install_callbacks_; |
| 82 // Component updater service observer, to determine when an on-demand |
| 83 // install request failed. |
| 84 scoped_ptr<PnaclUpdaterObserver> updater_observer_; |
62 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller); | 85 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller); |
63 }; | 86 }; |
64 | 87 |
65 // Returns true if this browser is compatible with the given Pnacl component | 88 // Returns true if this browser is compatible with the given Pnacl component |
66 // manifest, with the version specified in the manifest in |version_out|. | 89 // manifest, with the version specified in the manifest in |version_out|. |
67 bool CheckPnaclComponentManifest(const base::DictionaryValue& manifest, | 90 bool CheckPnaclComponentManifest(const base::DictionaryValue& manifest, |
68 base::Version* version_out); | 91 base::Version* version_out); |
69 | 92 |
| 93 // Ask the given component updater service to do a first-install for PNaCl. |
| 94 // The |installed| callback will be run with |true| on success, |
| 95 // or run with |false| on an error. The callback is called on the UI thread. |
| 96 void RequestFirstInstall(ComponentUpdateService* cus, |
| 97 PnaclComponentInstaller* pci, |
| 98 const base::Callback<void(bool)>& installed); |
| 99 |
70 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_ | 100 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_ |
OLD | NEW |