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

Side by Side Diff: chrome/browser/chromeos/drive/download_handler.cc

Issue 2853363002: Rename the DownloadService to DownloadCoreService (Closed)
Patch Set: Created 3 years, 7 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
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/drive/download_handler.h" 5 #include "chrome/browser/chromeos/drive/download_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/supports_user_data.h" 14 #include "base/supports_user_data.h"
15 #include "base/task_scheduler/post_task.h" 15 #include "base/task_scheduler/post_task.h"
16 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 18 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
19 #include "chrome/browser/chromeos/drive/file_system_util.h" 19 #include "chrome/browser/chromeos/drive/file_system_util.h"
20 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" 20 #include "chrome/browser/chromeos/drive/write_on_cache_file.h"
21 #include "chrome/browser/download/download_core_service.h"
22 #include "chrome/browser/download/download_core_service_factory.h"
21 #include "chrome/browser/download/download_history.h" 23 #include "chrome/browser/download/download_history.h"
22 #include "chrome/browser/download/download_service.h"
23 #include "chrome/browser/download/download_service_factory.h"
24 #include "components/drive/chromeos/file_system_interface.h" 24 #include "components/drive/chromeos/file_system_interface.h"
25 #include "components/drive/drive.pb.h" 25 #include "components/drive/drive.pb.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 using content::DownloadItem; 29 using content::DownloadItem;
30 using content::DownloadManager; 30 using content::DownloadManager;
31 31
32 namespace drive { 32 namespace drive {
33 namespace { 33 namespace {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 callback.Run(error == FILE_ERROR_OK); 110 callback.Run(error == FILE_ERROR_OK);
111 } 111 }
112 112
113 // Returns true if |download| is a Drive download created from data persisted 113 // Returns true if |download| is a Drive download created from data persisted
114 // on the download history DB. 114 // on the download history DB.
115 bool IsPersistedDriveDownload(const base::FilePath& drive_tmp_download_path, 115 bool IsPersistedDriveDownload(const base::FilePath& drive_tmp_download_path,
116 DownloadItem* download) { 116 DownloadItem* download) {
117 if (!drive_tmp_download_path.IsParent(download->GetTargetFilePath())) 117 if (!drive_tmp_download_path.IsParent(download->GetTargetFilePath()))
118 return false; 118 return false;
119 119
120 DownloadService* download_service = 120 DownloadCoreService* download_core_service =
121 DownloadServiceFactory::GetForBrowserContext( 121 DownloadCoreServiceFactory::GetForBrowserContext(
122 download->GetBrowserContext()); 122 download->GetBrowserContext());
123 DownloadHistory* download_history = download_service->GetDownloadHistory(); 123 DownloadHistory* download_history =
124 download_core_service->GetDownloadHistory();
124 125
125 return download_history && download_history->WasRestoredFromHistory(download); 126 return download_history && download_history->WasRestoredFromHistory(download);
126 } 127 }
127 128
128 // Returns an empty string |mime_type| was too generic that can be a result of 129 // Returns an empty string |mime_type| was too generic that can be a result of
129 // 'default' fallback choice on the HTTP server. In such a case, we ignore the 130 // 'default' fallback choice on the HTTP server. In such a case, we ignore the
130 // type so that our logic can guess by its own while uploading to Drive. 131 // type so that our logic can guess by its own while uploading to Drive.
131 std::string FilterOutGenericMimeType(const std::string& mime_type) { 132 std::string FilterOutGenericMimeType(const std::string& mime_type) {
132 for (size_t i = 0; i < arraysize(kGenericMimeTypes); ++i) { 133 for (size_t i = 0; i < arraysize(kGenericMimeTypes); ++i) {
133 if (base::LowerCaseEqualsASCII(mime_type, kGenericMimeTypes[i])) 134 if (base::LowerCaseEqualsASCII(mime_type, kGenericMimeTypes[i]))
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 426
426 DownloadManager* DownloadHandler::GetDownloadManager(void* manager_id) { 427 DownloadManager* DownloadHandler::GetDownloadManager(void* manager_id) {
427 if (manager_id == notifier_->GetManager()) 428 if (manager_id == notifier_->GetManager())
428 return notifier_->GetManager(); 429 return notifier_->GetManager();
429 if (notifier_incognito_ && manager_id == notifier_incognito_->GetManager()) 430 if (notifier_incognito_ && manager_id == notifier_incognito_->GetManager())
430 return notifier_incognito_->GetManager(); 431 return notifier_incognito_->GetManager();
431 return NULL; 432 return NULL;
432 } 433 }
433 434
434 } // namespace drive 435 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698