OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "chrome/browser/extensions/active_install_data.h" | |
6 | |
7 #include "chrome/browser/extensions/install_tracker.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 | |
10 namespace extensions { | |
11 | |
12 // ActiveInstallData: | |
13 | |
14 ActiveInstallData::ActiveInstallData() | |
15 : percent_downloaded(0), is_ephemeral(false) { | |
16 } | |
17 | |
18 ActiveInstallData::ActiveInstallData(const std::string& extension_id) | |
19 : extension_id(extension_id), percent_downloaded(0), is_ephemeral(false) { | |
20 } | |
21 | |
22 // ScopedActiveInstall: | |
23 | |
24 ScopedActiveInstall::ScopedActiveInstall(Profile* profile, | |
25 const ActiveInstallData& install_data) | |
26 : profile_(profile), extension_id_(install_data.extension_id) { | |
27 DCHECK(profile); | |
28 DCHECK(!install_data.extension_id.empty()); | |
29 | |
30 InstallTracker* tracker = InstallTracker::Get(profile); | |
31 DCHECK(tracker); | |
32 tracker->AddActiveInstall(install_data); | |
33 } | |
34 | |
35 ScopedActiveInstall::ScopedActiveInstall(Profile* profile, | |
36 const std::string& extension_id) | |
37 : profile_(profile), extension_id_(extension_id) { | |
38 DCHECK(profile); | |
39 DCHECK(!extension_id.empty()); | |
40 } | |
41 | |
42 ScopedActiveInstall::~ScopedActiveInstall() { | |
43 if (!extension_id_.empty()) { | |
44 InstallTracker* tracker = InstallTracker::Get(profile_); | |
asargent_no_longer_on_chrome
2014/07/17 06:24:51
I'm a little concerned about this class holding a
| |
45 DCHECK(tracker); | |
46 tracker->RemoveActiveInstall(extension_id_); | |
47 } | |
48 } | |
49 | |
50 void ScopedActiveInstall::CancelDeregister() { | |
51 extension_id_.clear(); | |
52 } | |
53 | |
54 } // namespace extensions | |
OLD | NEW |