Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_download_observer.cc

Issue 9809011: GData save package support with MHTML. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chromeos/gdata/gdata_download_observer.h" 5 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
6 6
7 #include "base/file_util.h"
7 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" 8 #include "chrome/browser/chromeos/gdata/gdata_uploader.h"
8 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" 9 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h"
9 #include "chrome/browser/chromeos/gdata/gdata_util.h" 10 #include "chrome/browser/chromeos/gdata/gdata_util.h"
10 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
11 12
12 using content::BrowserThread; 13 using content::BrowserThread;
13 using content::DownloadManager; 14 using content::DownloadManager;
14 using content::DownloadItem; 15 using content::DownloadItem;
15 16
16 namespace gdata { 17 namespace gdata {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // count of received bytes and the size of the download as given by the 147 // count of received bytes and the size of the download as given by the
147 // Content-Length header. 148 // Content-Length header.
148 int64 total = (download->AllDataSaved() ? download->GetReceivedBytes() : 149 int64 total = (download->AllDataSaved() ? download->GetReceivedBytes() :
149 download->GetTotalBytes()); 150 download->GetTotalBytes());
150 DCHECK(total <= 0 || complete < total); 151 DCHECK(total <= 0 || complete < total);
151 if (total > 0) 152 if (total > 0)
152 return static_cast<int>((complete * 100.0) / total); 153 return static_cast<int>((complete * 100.0) / total);
153 return -1; 154 return -1;
154 } 155 }
155 156
157 // |gdata_tmp_download_path| is set to a temporary local download path in
158 // ~/GCache/v1/tmp/downloads/
159 void GDataDownloadObserver::GetGDataTempDownloadPath(
asanka 2012/03/26 16:50:14 // static
achuithb 2012/03/26 19:51:39 Done.
160 const FilePath& gdata_tmp_download_dir,
161 FilePath* gdata_tmp_download_path) {
162 bool created = file_util::CreateDirectory(gdata_tmp_download_dir);
163 DCHECK(created) << "Can not create temp download directory at "
164 << gdata_tmp_download_dir.value();
165 created = file_util::CreateTemporaryFileInDir(gdata_tmp_download_dir,
166 gdata_tmp_download_path);
167 DCHECK(created) << "Temporary download file creation failed";
168 }
169
156 void GDataDownloadObserver::ManagerGoingDown( 170 void GDataDownloadObserver::ManagerGoingDown(
157 DownloadManager* download_manager) { 171 DownloadManager* download_manager) {
158 download_manager->RemoveObserver(this); 172 download_manager->RemoveObserver(this);
159 download_manager_ = NULL; 173 download_manager_ = NULL;
160 } 174 }
161 175
162 void GDataDownloadObserver::ModelChanged(DownloadManager* download_manager) { 176 void GDataDownloadObserver::ModelChanged(DownloadManager* download_manager) {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
164 178
165 DownloadManager::DownloadVector downloads; 179 DownloadManager::DownloadVector downloads;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return; 323 return;
310 DVLOG(1) << "Completing upload for download ID " << download_id; 324 DVLOG(1) << "Completing upload for download ID " << download_id;
311 DownloadItem* download = iter->second; 325 DownloadItem* download = iter->second;
312 UploadingExternalData* upload_data = GetUploadingExternalData(download); 326 UploadingExternalData* upload_data = GetUploadingExternalData(download);
313 DCHECK(upload_data); 327 DCHECK(upload_data);
314 upload_data->MarkAsComplete(); 328 upload_data->MarkAsComplete();
315 download->MaybeCompleteDownload(); 329 download->MaybeCompleteDownload();
316 } 330 }
317 331
318 } // namespace gdata 332 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698