| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webstore_installer.h" | 5 #include "chrome/browser/extensions/webstore_installer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 InstallSource source) | 251 InstallSource source) |
| 252 : content::WebContentsObserver(web_contents), | 252 : content::WebContentsObserver(web_contents), |
| 253 profile_(profile), | 253 profile_(profile), |
| 254 delegate_(delegate), | 254 delegate_(delegate), |
| 255 id_(id), | 255 id_(id), |
| 256 install_source_(source), | 256 install_source_(source), |
| 257 download_item_(NULL), | 257 download_item_(NULL), |
| 258 approval_(approval.release()), | 258 approval_(approval.release()), |
| 259 total_modules_(0), | 259 total_modules_(0), |
| 260 download_started_(false) { | 260 download_started_(false) { |
| 261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 261 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 262 DCHECK(web_contents); | 262 DCHECK(web_contents); |
| 263 | 263 |
| 264 registrar_.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 264 registrar_.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 265 content::NotificationService::AllSources()); | 265 content::NotificationService::AllSources()); |
| 266 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 266 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 267 content::Source<Profile>(profile->GetOriginalProfile())); | 267 content::Source<Profile>(profile->GetOriginalProfile())); |
| 268 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 268 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 269 content::Source<CrxInstaller>(NULL)); | 269 content::Source<CrxInstaller>(NULL)); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void WebstoreInstaller::Start() { | 272 void WebstoreInstaller::Start() { |
| 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 273 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 274 AddRef(); // Balanced in ReportSuccess and ReportFailure. | 274 AddRef(); // Balanced in ReportSuccess and ReportFailure. |
| 275 | 275 |
| 276 if (!Extension::IdIsValid(id_)) { | 276 if (!Extension::IdIsValid(id_)) { |
| 277 ReportFailure(kInvalidIdError, FAILURE_REASON_OTHER); | 277 ReportFailure(kInvalidIdError, FAILURE_REASON_OTHER); |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 | 280 |
| 281 ExtensionService* extension_service = | 281 ExtensionService* extension_service = |
| 282 ExtensionSystem::Get(profile_)->extension_service(); | 282 ExtensionSystem::Get(profile_)->extension_service(); |
| 283 if (approval_.get() && approval_->dummy_extension) { | 283 if (approval_.get() && approval_->dummy_extension) { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 545 |
| 546 // http://crbug.com/165634 | 546 // http://crbug.com/165634 |
| 547 // http://crbug.com/126013 | 547 // http://crbug.com/126013 |
| 548 // The current working theory is that one of the many pointers dereferenced in | 548 // The current working theory is that one of the many pointers dereferenced in |
| 549 // here is occasionally deleted before all of its referers are nullified, | 549 // here is occasionally deleted before all of its referers are nullified, |
| 550 // probably in a callback race. After this comment is released, the crash | 550 // probably in a callback race. After this comment is released, the crash |
| 551 // reports should narrow down exactly which pointer it is. Collapsing all the | 551 // reports should narrow down exactly which pointer it is. Collapsing all the |
| 552 // early-returns into a single branch makes it hard to see exactly which pointer | 552 // early-returns into a single branch makes it hard to see exactly which pointer |
| 553 // it is. | 553 // it is. |
| 554 void WebstoreInstaller::StartDownload(const base::FilePath& file) { | 554 void WebstoreInstaller::StartDownload(const base::FilePath& file) { |
| 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 555 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 556 | 556 |
| 557 if (file.empty()) { | 557 if (file.empty()) { |
| 558 ReportFailure(kDownloadDirectoryError, FAILURE_REASON_OTHER); | 558 ReportFailure(kDownloadDirectoryError, FAILURE_REASON_OTHER); |
| 559 return; | 559 return; |
| 560 } | 560 } |
| 561 | 561 |
| 562 DownloadManager* download_manager = | 562 DownloadManager* download_manager = |
| 563 BrowserContext::GetDownloadManager(profile_); | 563 BrowserContext::GetDownloadManager(profile_); |
| 564 if (!download_manager) { | 564 if (!download_manager) { |
| 565 ReportFailure(kDownloadDirectoryError, FAILURE_REASON_OTHER); | 565 ReportFailure(kDownloadDirectoryError, FAILURE_REASON_OTHER); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 1, | 693 1, |
| 694 kMaxSizeKb, | 694 kMaxSizeKb, |
| 695 kNumBuckets); | 695 kNumBuckets); |
| 696 } | 696 } |
| 697 UMA_HISTOGRAM_BOOLEAN( | 697 UMA_HISTOGRAM_BOOLEAN( |
| 698 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", | 698 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", |
| 699 total_bytes <= 0); | 699 total_bytes <= 0); |
| 700 } | 700 } |
| 701 | 701 |
| 702 } // namespace extensions | 702 } // namespace extensions |
| OLD | NEW |