OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/component_updater/pnacl/pnacl_updater_observer.h" | |
6 | |
7 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" | |
8 #include "content/public/browser/browser_thread.h" | |
9 | |
10 using content::BrowserThread; | |
11 | |
12 PnaclUpdaterObserver::PnaclUpdaterObserver(PnaclComponentInstaller* pci) | |
13 : must_observe_(false), pnacl_installer_(pci) {} | |
14 | |
15 PnaclUpdaterObserver::~PnaclUpdaterObserver() {} | |
16 | |
17 void PnaclUpdaterObserver::EnsureObserving() { | |
18 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
19 must_observe_ = true; | |
20 } | |
21 | |
22 void PnaclUpdaterObserver::StopObserving() { | |
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
24 must_observe_ = false; | |
25 } | |
26 | |
27 void PnaclUpdaterObserver::OnEvent(Events event, int extra) { | |
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
29 if (must_observe_) { | |
30 switch (event) { | |
31 default: | |
32 break; | |
33 case COMPONENT_UPDATE_READY: | |
34 // If the component updater says there is an UPDATE_READY w/ source | |
35 // being the PNaCl ID, then installation is handed off to the PNaCl | |
36 // installer and we can stop observing. The installer will be the one | |
37 // to run the callback w/ success or failure. | |
38 must_observe_ = false; | |
39 break; | |
40 case COMPONENT_UPDATER_SLEEPING: | |
41 // If the component updater sleeps before an UPDATE_READY for this | |
42 // component, then requests for installs were likely skipped, | |
43 // an error occurred, or there was no new update. | |
44 must_observe_ = false; | |
45 pnacl_installer_->NotifyInstallError(); | |
46 break; | |
47 } | |
48 } | |
49 } | |
OLD | NEW |