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" |
13 | 16 |
14 class CommandLine; | 17 class CommandLine; |
15 | 18 |
16 namespace base { | 19 namespace base { |
17 class DictionaryValue; | 20 class DictionaryValue; |
(...skipping 28 matching lines...) Expand all Loading... |
46 | 49 |
47 // Determine the base directory for storing each version of PNaCl. | 50 // Determine the base directory for storing each version of PNaCl. |
48 base::FilePath GetPnaclBaseDirectory(); | 51 base::FilePath GetPnaclBaseDirectory(); |
49 | 52 |
50 base::Version current_version() const { return current_version_; } | 53 base::Version current_version() const { return current_version_; } |
51 | 54 |
52 void set_current_version(const base::Version& v) { current_version_ = v; } | 55 void set_current_version(const base::Version& v) { current_version_ = v; } |
53 | 56 |
54 ComponentUpdateService* cus() const { return cus_; } | 57 ComponentUpdateService* cus() const { return cus_; } |
55 | 58 |
| 59 typedef base::Callback<void(bool)> InstallCallback; |
| 60 void AddInstallCallback(const InstallCallback& cb); |
| 61 |
56 private: | 62 private: |
| 63 // Cancel a particular callback after a timeout. |
| 64 void CancelCallback(int callback_num); |
| 65 |
| 66 void NotifyAllWithResult(bool status); |
| 67 void NotifyInstallError(); |
| 68 void NotifyInstallSuccess(); |
| 69 |
57 bool per_user_; | 70 bool per_user_; |
58 scoped_ptr<PnaclProfileObserver> profile_observer_; | 71 scoped_ptr<PnaclProfileObserver> profile_observer_; |
59 base::FilePath current_profile_path_; | 72 base::FilePath current_profile_path_; |
60 base::Version current_version_; | 73 base::Version current_version_; |
61 ComponentUpdateService* cus_; | 74 ComponentUpdateService* cus_; |
| 75 // Counter to issue identifiers to each callback. |
| 76 int callback_nums_; |
| 77 // List of callbacks to issue when an install completes successfully. |
| 78 std::list<std::pair<InstallCallback, int> > install_callbacks_; |
62 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller); | 79 DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller); |
63 }; | 80 }; |
64 | 81 |
65 // Returns true if this browser is compatible with the given Pnacl component | 82 // Returns true if this browser is compatible with the given Pnacl component |
66 // manifest, with the version specified in the manifest in |version_out|. | 83 // manifest, with the version specified in the manifest in |version_out|. |
67 bool CheckPnaclComponentManifest(const base::DictionaryValue& manifest, | 84 bool CheckPnaclComponentManifest(const base::DictionaryValue& manifest, |
68 base::Version* version_out); | 85 base::Version* version_out); |
69 | 86 |
| 87 // Ask the given component updater service to do a first-install for PNaCl. |
| 88 // The |installed| callback will be run with |true| on success, |
| 89 // or run with |false| on an error. The callback is called on the UI thread. |
| 90 void RequestFirstInstall(ComponentUpdateService* cus, |
| 91 PnaclComponentInstaller* pci, |
| 92 const base::Callback<void(bool)>& installed); |
| 93 |
70 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_ | 94 #endif // CHROME_BROWSER_COMPONENT_UPDATER_PNACL_PNACL_COMPONENT_INSTALLER_H_ |
OLD | NEW |