app_list: Re-enable people search.
[chromium-blink-merge.git] / chrome / browser / extensions / active_install_data.cc
blobf9c9a0c878149c56fac166a0962fcc808983d146
1 // Copyright 2014 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.
5 #include "chrome/browser/extensions/active_install_data.h"
7 #include "chrome/browser/extensions/install_tracker.h"
9 namespace extensions {
11 // ActiveInstallData:
13 ActiveInstallData::ActiveInstallData()
14 : percent_downloaded(0), is_ephemeral(false) {
17 ActiveInstallData::ActiveInstallData(const std::string& extension_id)
18 : extension_id(extension_id), percent_downloaded(0), is_ephemeral(false) {
21 // ScopedActiveInstall:
23 ScopedActiveInstall::ScopedActiveInstall(InstallTracker* tracker,
24 const ActiveInstallData& install_data)
25 : tracker_(tracker),
26 tracker_observer_(this),
27 extension_id_(install_data.extension_id) {
28 Init();
29 tracker_->AddActiveInstall(install_data);
32 ScopedActiveInstall::ScopedActiveInstall(InstallTracker* tracker,
33 const std::string& extension_id)
34 : tracker_(tracker), tracker_observer_(this), extension_id_(extension_id) {
35 Init();
38 ScopedActiveInstall::~ScopedActiveInstall() {
39 if (tracker_)
40 tracker_->RemoveActiveInstall(extension_id_);
43 void ScopedActiveInstall::CancelDeregister() {
44 tracker_observer_.RemoveAll();
45 tracker_ = NULL;
48 void ScopedActiveInstall::Init() {
49 DCHECK(!extension_id_.empty());
50 DCHECK(tracker_);
51 tracker_observer_.Add(tracker_);
54 void ScopedActiveInstall::OnShutdown() {
55 CancelDeregister();
58 } // namespace extensions