| Index: chrome/browser/extensions/api/image_writer_private/operation.cc
|
| diff --git a/chrome/browser/extensions/api/image_writer_private/operation.cc b/chrome/browser/extensions/api/image_writer_private/operation.cc
|
| index a37c81c4e6755c4b553f9f820b04bd53e9d103da..fa8c113a91570aca7e97e294190e39216c7d734f 100644
|
| --- a/chrome/browser/extensions/api/image_writer_private/operation.cc
|
| +++ b/chrome/browser/extensions/api/image_writer_private/operation.cc
|
| @@ -36,14 +36,11 @@ Operation::Operation(base::WeakPtr<OperationManager> manager,
|
| progress_(0) {
|
| }
|
|
|
| -Operation::~Operation() {
|
| -}
|
| +Operation::~Operation() {}
|
|
|
| void Operation::Cancel() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
|
|
| - DVLOG(1) << "Cancelling image writing operation for ext: " << extension_id_;
|
| -
|
| stage_ = image_writer_api::STAGE_NONE;
|
|
|
| CleanUp();
|
| @@ -144,7 +141,6 @@ void Operation::Finish() {
|
| base::Bind(&Operation::Finish, this));
|
| return;
|
| }
|
| - DVLOG(1) << "Write operation complete.";
|
|
|
| CleanUp();
|
|
|
| @@ -178,13 +174,41 @@ void Operation::CleanUp() {
|
| cleanup_functions_.clear();
|
| }
|
|
|
| -void Operation::UnzipStart(scoped_ptr<base::FilePath> zip_path) {
|
| +void Operation::StartImageWriterClient() {
|
| + if (!image_writer_client_) {
|
| + image_writer_client_ = new ImageWriterClient();
|
| +
|
| + AddCleanUpFunction(base::Bind(&Operation::StopImageWriterClient, this));
|
| + }
|
| +}
|
| +
|
| +void Operation::StopImageWriterClient() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| +
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&ImageWriterClient::Shutdown, image_writer_client_));
|
| +}
|
| +
|
| +void Operation::WriteImageProgress(int64 total_bytes, int64 curr_bytes) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| if (IsCancelled()) {
|
| return;
|
| }
|
|
|
| - DVLOG(1) << "Starting unzip stage for " << zip_path->value();
|
| + int progress = kProgressComplete * curr_bytes / total_bytes;
|
| +
|
| + if (progress > GetProgress()) {
|
| + SetProgress(progress);
|
| + }
|
| +}
|
| +
|
| +void Operation::UnzipStart(scoped_ptr<base::FilePath> zip_path) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| + if (IsCancelled()) {
|
| + return;
|
| + }
|
|
|
| SetStage(image_writer_api::STAGE_UNZIP);
|
|
|
| @@ -335,8 +359,9 @@ void Operation::OnUnzipFailure() {
|
| void Operation::OnUnzipProgress(int64 total_bytes, int64 progress_bytes) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
|
|
| - int progress_percent = 100 * progress_bytes / total_bytes;
|
| - SetProgress(progress_percent);
|
| + int progress_percent = kProgressComplete * progress_bytes / total_bytes;
|
| + if (progress_percent > GetProgress())
|
| + SetProgress(progress_percent);
|
| }
|
|
|
| } // namespace image_writer
|
|
|