OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/extensions/updater/extension_cache_impl.h" | 5 #include "chrome/browser/extensions/updater/extension_cache_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 : weak_ptr_factory_(this), | 44 : weak_ptr_factory_(this), |
45 cache_(new LocalExtensionCache(base::FilePath(kLocalCacheDir), | 45 cache_(new LocalExtensionCache(base::FilePath(kLocalCacheDir), |
46 kMaxCacheSize, | 46 kMaxCacheSize, |
47 base::TimeDelta::FromDays(kMaxCacheAgeDays), | 47 base::TimeDelta::FromDays(kMaxCacheAgeDays), |
48 content::BrowserThread::GetBlockingPool()-> | 48 content::BrowserThread::GetBlockingPool()-> |
49 GetSequencedTaskRunnerWithShutdownBehavior( | 49 GetSequencedTaskRunnerWithShutdownBehavior( |
50 content::BrowserThread::GetBlockingPool()->GetSequenceToken(), | 50 content::BrowserThread::GetBlockingPool()->GetSequenceToken(), |
51 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))) { | 51 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))) { |
52 notification_registrar_.Add( | 52 notification_registrar_.Add( |
53 this, | 53 this, |
54 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 54 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
55 content::NotificationService::AllBrowserContextsAndSources()); | 55 content::NotificationService::AllBrowserContextsAndSources()); |
56 cache_->Init(true, base::Bind(&ExtensionCacheImpl::OnCacheInitialized, | 56 cache_->Init(true, base::Bind(&ExtensionCacheImpl::OnCacheInitialized, |
57 weak_ptr_factory_.GetWeakPtr())); | 57 weak_ptr_factory_.GetWeakPtr())); |
58 } | 58 } |
59 | 59 |
60 ExtensionCacheImpl::~ExtensionCacheImpl() { | 60 ExtensionCacheImpl::~ExtensionCacheImpl() { |
61 } | 61 } |
62 | 62 |
63 void ExtensionCacheImpl::Start(const base::Closure& callback) { | 63 void ExtensionCacheImpl::Start(const base::Closure& callback) { |
64 if (!cache_ || cache_->is_ready()) { | 64 if (!cache_ || cache_->is_ready()) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 void ExtensionCacheImpl::Observe(int type, | 119 void ExtensionCacheImpl::Observe(int type, |
120 const content::NotificationSource& source, | 120 const content::NotificationSource& source, |
121 const content::NotificationDetails& details) { | 121 const content::NotificationDetails& details) { |
122 if (!cache_) | 122 if (!cache_) |
123 return; | 123 return; |
124 | 124 |
125 switch (type) { | 125 switch (type) { |
126 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { | 126 case extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR: { |
127 extensions::CrxInstaller* installer = | 127 extensions::CrxInstaller* installer = |
128 content::Source<extensions::CrxInstaller>(source).ptr(); | 128 content::Source<extensions::CrxInstaller>(source).ptr(); |
129 // TODO(dpolukhin): remove extension from cache only if installation | 129 // TODO(dpolukhin): remove extension from cache only if installation |
130 // failed due to file corruption. | 130 // failed due to file corruption. |
131 cache_->RemoveExtension(installer->expected_id()); | 131 cache_->RemoveExtension(installer->expected_id()); |
132 break; | 132 break; |
133 } | 133 } |
134 | 134 |
135 default: | 135 default: |
136 NOTREACHED(); | 136 NOTREACHED(); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 } // namespace extensions | 140 } // namespace extensions |
OLD | NEW |