Commit d5cf4dc4 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Remove unused DownloadHandler

Bug: 1003238
Change-Id: Icc3227b44ba58fcab17bd8eab959f0346a8a906d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886133Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710238}
parent af56e43c
......@@ -883,8 +883,6 @@ source_set("chromeos") {
"display/quirks_manager_delegate_impl.h",
"drive/debug_info_collector.cc",
"drive/debug_info_collector.h",
"drive/download_handler.cc",
"drive/download_handler.h",
"drive/drive_integration_service.cc",
"drive/drive_integration_service.h",
"drive/file_system_util.cc",
......@@ -2581,7 +2579,6 @@ source_set("unit_tests") {
"cryptauth/client_app_metadata_provider_service_unittest.cc",
"customization/customization_document_unittest.cc",
"dbus/proxy_resolution_service_provider_unittest.cc",
"drive/download_handler_unittest.cc",
"drive/drive_integration_service_unittest.cc",
"drive/file_system_util_unittest.cc",
"drive/write_on_cache_file_unittest.cc",
......
This diff is collapsed.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_
#include <stdint.h>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/download/content/public/all_download_item_notifier.h"
#include "components/drive/file_errors.h"
#include "content/public/browser/download_manager_delegate.h"
class Profile;
namespace content {
class DownloadManager;
}
namespace download {
class DownloadItem;
}
namespace drive {
class FileSystemInterface;
// Observes downloads to temporary local drive folder. Schedules these
// downloads for upload to drive service.
class DownloadHandler : public download::AllDownloadItemNotifier::Observer {
public:
explicit DownloadHandler(FileSystemInterface* file_system);
~DownloadHandler() override;
// Utility method to get DownloadHandler with profile.
static DownloadHandler* GetForProfile(Profile* profile);
// Become an observer of DownloadManager.
void Initialize(content::DownloadManager* download_manager,
const base::FilePath& drive_tmp_download_path);
// In addition to the DownloadManager passed to Initialize(), observe another
// download manager. This should be called only for the DownloadManager of the
// incognito version of the profile where |file_system_| resides.
void ObserveIncognitoDownloadManager(
content::DownloadManager* download_manager);
// Callback used to return results from SubstituteDriveDownloadPath.
// TODO(hashimoto): Report error with a FileError. crbug.com/171345
typedef base::Callback<void(const base::FilePath&)>
SubstituteDriveDownloadPathCallback;
void SubstituteDriveDownloadPath(
const base::FilePath& drive_path,
download::DownloadItem* download,
const SubstituteDriveDownloadPathCallback& callback);
// Sets drive path, for example, '/special/drive/MyFolder/MyFile',
// to external data in |download|. Also sets display name and
// makes |download| a temporary.
void SetDownloadParams(const base::FilePath& drive_path,
download::DownloadItem* download);
// Gets the target drive path from external data in |download|.
base::FilePath GetTargetPath(const download::DownloadItem* download);
// Gets the downloaded drive cache file path from external data in |download|.
base::FilePath GetCacheFilePath(const download::DownloadItem* download);
// Checks if there is a Drive upload associated with |download|
bool IsDriveDownload(const download::DownloadItem* download);
// Checks a file corresponding to the download item exists in Drive.
void CheckForFileExistence(const download::DownloadItem* download,
content::CheckForFileExistenceCallback callback);
// Calculates request space for |downloads|.
int64_t CalculateRequestSpace(
const content::DownloadManager::DownloadVector& downloads);
// Checks available storage space and free disk space if necessary. Actual
// execution is delayed and rate limited.
void FreeDiskSpaceIfNeeded();
// Checks available storage space and free disk space if necessary. This is
// executed immediately.
void FreeDiskSpaceIfNeededImmediately();
// Sets free disk space delay for testing.
void SetFreeDiskSpaceDelayForTesting(const base::TimeDelta& delay);
private:
// AllDownloadItemNotifier::Observer overrides:
void OnDownloadCreated(content::DownloadManager* manager,
download::DownloadItem* download) override;
void OnDownloadUpdated(content::DownloadManager* manager,
download::DownloadItem* download) override;
// Removes the download.
void RemoveDownload(void* manager_id, int id);
// Callback for FileSystem::CreateDirectory().
// Used to implement SubstituteDriveDownloadPath().
void OnCreateDirectory(const SubstituteDriveDownloadPathCallback& callback,
FileError error);
// Starts the upload of a downloaded/downloading file.
void UploadDownloadItem(content::DownloadManager* manager,
download::DownloadItem* download);
// Sets |cache_file_path| as user data of the download item specified by |id|.
void SetCacheFilePath(void* manager_id,
int id,
const base::FilePath* cache_file_path,
FileError error);
// Gets a download manager, given a |manager_id| casted from the pointer to
// the manager. This is used to validate the manager that may be deleted while
// asynchronous task posting. Returns NULL if the manager is already gone.
content::DownloadManager* GetDownloadManager(void* manager_id);
FileSystemInterface* file_system_; // Owned by DriveIntegrationService.
// Observe the DownloadManager for new downloads.
std::unique_ptr<download::AllDownloadItemNotifier> notifier_;
std::unique_ptr<download::AllDownloadItemNotifier> notifier_incognito_;
// Temporary download location directory.
base::FilePath drive_tmp_download_path_;
// True if there is pending FreeDiskSpaceIfNeeded call.
bool has_pending_free_disk_space_;
base::TimeDelta free_disk_space_delay_;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DownloadHandler);
};
} // namespace drive
#endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_
......@@ -25,7 +25,6 @@
#include "base/unguessable_token.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/drive/debug_info_collector.h"
#include "chrome/browser/chromeos/drive/download_handler.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
......@@ -733,7 +732,6 @@ DriveIntegrationService::DriveIntegrationService(
logger_.get(), cache_.get(), scheduler_.get(),
resource_metadata_.get(), blocking_task_runner_.get(),
cache_root_directory_.Append(kTemporaryFileDirectory)));
download_handler_ = std::make_unique<DownloadHandler>(file_system());
debug_info_collector_ = std::make_unique<DebugInfoCollector>(
resource_metadata_.get(), file_system(), blocking_task_runner_.get());
......@@ -762,7 +760,6 @@ void DriveIntegrationService::Shutdown() {
RemoveDriveMountPoint();
notification_manager_.reset();
debug_info_collector_.reset();
download_handler_.reset();
file_system_.reset();
scheduler_.reset();
drive_service_.reset();
......@@ -1167,25 +1164,6 @@ void DriveIntegrationService::InitializeAfterMetadataInitialized(
// migrated and any dirty files are recovered whenever switching to DriveFS.
profile_->GetPrefs()->ClearPref(prefs::kDriveFsPinnedMigrated);
// Initialize Download Handler for hooking downloads to the Drive folder.
content::DownloadManager* download_manager =
g_browser_process->download_status_updater()
? BrowserContext::GetDownloadManager(profile_)
: nullptr;
download_handler_->Initialize(
download_manager,
cache_root_directory_.Append(kTemporaryFileDirectory));
// Install the handler also to incognito profile.
if (g_browser_process->download_status_updater()) {
if (profile_->HasOffTheRecordProfile()) {
download_handler_->ObserveIncognitoDownloadManager(
BrowserContext::GetDownloadManager(
profile_->GetOffTheRecordProfile()));
}
observed_profiles_.Add(profile_);
}
// Register for Google Drive invalidation notifications.
DriveNotificationManager* drive_notification_manager =
DriveNotificationManagerFactory::GetForBrowserContext(profile_);
......@@ -1226,13 +1204,6 @@ bool DriveIntegrationService::DownloadDirectoryPreferenceIsInDrive() {
GetMountPointPath().IsParent(downloads_path);
}
void DriveIntegrationService::OnOffTheRecordProfileCreated(
Profile* off_the_record) {
DCHECK_EQ(profile_, off_the_record->GetOriginalProfile());
download_handler_->ObserveIncognitoDownloadManager(
BrowserContext::GetDownloadManager(off_the_record));
}
void DriveIntegrationService::MigratePinnedFiles() {
if (!metadata_storage_)
return;
......
......@@ -16,7 +16,6 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "chromeos/components/drivefs/drivefs_host.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "components/drive/drive_notification_observer.h"
......@@ -44,7 +43,6 @@ class DriveFs;
namespace drive {
class DebugInfoCollector;
class DownloadHandler;
class DriveServiceInterface;
class EventLogger;
class FileSystemInterface;
......@@ -103,7 +101,6 @@ class DriveIntegrationServiceObserver {
// created per-profile.
class DriveIntegrationService : public KeyedService,
public DriveNotificationObserver,
public ProfileObserver,
public drivefs::DriveFsHost::MountObserver,
public chromeos::PowerManagerClient::Observer {
public:
......@@ -175,7 +172,6 @@ class DriveIntegrationService : public KeyedService,
return debug_info_collector_.get();
}
FileSystemInterface* file_system() { return file_system_.get(); }
DownloadHandler* download_handler() { return download_handler_.get(); }
JobListInterface* job_list() { return scheduler_.get(); }
// Clears all the local cache file, the local resource metadata, and
......@@ -248,9 +244,6 @@ class DriveIntegrationService : public KeyedService,
bool DownloadDirectoryPreferenceIsInDrive();
// ProfileObserver:
void OnOffTheRecordProfileCreated(Profile* off_the_record) override;
// Migrate pinned files from the old Drive integration to DriveFS.
void MigratePinnedFiles();
......@@ -286,7 +279,6 @@ class DriveIntegrationService : public KeyedService,
std::unique_ptr<internal::ResourceMetadata, util::DestroyHelper>
resource_metadata_;
std::unique_ptr<FileSystemInterface> file_system_;
std::unique_ptr<DownloadHandler> download_handler_;
std::unique_ptr<DebugInfoCollector> debug_info_collector_;
base::ObserverList<DriveIntegrationServiceObserver>::Unchecked observers_;
......@@ -303,7 +295,6 @@ class DriveIntegrationService : public KeyedService,
ScopedObserver<chromeos::PowerManagerClient,
chromeos::PowerManagerClient::Observer>
power_manager_observer_{this};
ScopedObserver<Profile, ProfileObserver> observed_profiles_{this};
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment