Commit ce5bb691 authored by Sergei Datsenko's avatar Sergei Datsenko Committed by Commit Bot

Cache tokens inside DriveFsHost for remounts

If drivefs needs to restart there is no need to redo all the job for
oauth token minting as the previous one should still be good.

BUG=chromium:897558

Change-Id: I4e1737a94a70476c6312ff11c04b8f3f233e4512
Reviewed-on: https://chromium-review.googlesource.com/c/1293058
Commit-Queue: Sergei Datsenko <dats@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601877}
parent 1b13290f
...@@ -464,6 +464,8 @@ class DriveIntegrationService::DriveFsHolder ...@@ -464,6 +464,8 @@ class DriveIntegrationService::DriveFsHolder
drivefs_host_(profile_->GetPath(), drivefs_host_(profile_->GetPath(),
this, this,
this, this,
base::DefaultClock::GetInstance(),
chromeos::disks::DiskMountManager::GetInstance(),
std::make_unique<base::OneShotTimer>()) {} std::make_unique<base::OneShotTimer>()) {}
drivefs::DriveFsHost* drivefs_host() { return &drivefs_host_; } drivefs::DriveFsHost* drivefs_host() { return &drivefs_host_; }
......
This diff is collapsed.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/time/clock.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h" #include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "chromeos/disks/disk_mount_manager.h" #include "chromeos/disks/disk_mount_manager.h"
...@@ -32,6 +33,12 @@ namespace service_manager { ...@@ -32,6 +33,12 @@ namespace service_manager {
class Connector; class Connector;
} // namespace service_manager } // namespace service_manager
namespace chromeos {
namespace disks {
class DiskMountManager;
}
} // namespace chromeos
namespace drivefs { namespace drivefs {
class DriveFsHostObserver; class DriveFsHostObserver;
...@@ -94,6 +101,8 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost { ...@@ -94,6 +101,8 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost {
DriveFsHost(const base::FilePath& profile_path, DriveFsHost(const base::FilePath& profile_path,
Delegate* delegate, Delegate* delegate,
MountObserver* mount_observer, MountObserver* mount_observer,
const base::Clock* clock,
chromeos::disks::DiskMountManager* disk_mount_manager,
std::unique_ptr<base::OneShotTimer> timer); std::unique_ptr<base::OneShotTimer> timer);
~DriveFsHost(); ~DriveFsHost();
...@@ -118,6 +127,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost { ...@@ -118,6 +127,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost {
mojom::DriveFs* GetDriveFsInterface() const; mojom::DriveFs* GetDriveFsInterface() const;
private: private:
class AccountTokenDelegate;
class MountState; class MountState;
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
...@@ -127,9 +137,12 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost { ...@@ -127,9 +137,12 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost {
Delegate* const delegate_; Delegate* const delegate_;
MountObserver* const mount_observer_; MountObserver* const mount_observer_;
const base::Clock* const clock_;
chromeos::disks::DiskMountManager* const disk_mount_manager_;
std::unique_ptr<base::OneShotTimer> timer_; std::unique_ptr<base::OneShotTimer> timer_;
std::unique_ptr<AccountTokenDelegate> account_token_delegate_;
// State specific to the current mount, or null if not mounted. // State specific to the current mount, or null if not mounted.
std::unique_ptr<MountState> mount_state_; std::unique_ptr<MountState> mount_state_;
......
...@@ -56,22 +56,16 @@ std::unique_ptr<Disk::Builder> MakeDiskBuilder() { ...@@ -56,22 +56,16 @@ std::unique_ptr<Disk::Builder> MakeDiskBuilder() {
} // namespace } // namespace
void MockDiskMountManager::AddObserverInternal( void MockDiskMountManager::AddObserver(DiskMountManager::Observer* observer) {
DiskMountManager::Observer* observer) {
observers_.AddObserver(observer); observers_.AddObserver(observer);
} }
void MockDiskMountManager::RemoveObserverInternal( void MockDiskMountManager::RemoveObserver(
DiskMountManager::Observer* observer) { DiskMountManager::Observer* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
MockDiskMountManager::MockDiskMountManager() { MockDiskMountManager::MockDiskMountManager() {
ON_CALL(*this, AddObserver(_))
.WillByDefault(Invoke(this, &MockDiskMountManager::AddObserverInternal));
ON_CALL(*this, RemoveObserver(_))
.WillByDefault(Invoke(this,
&MockDiskMountManager::RemoveObserverInternal));
ON_CALL(*this, disks()) ON_CALL(*this, disks())
.WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal)); .WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal));
ON_CALL(*this, mount_points()) ON_CALL(*this, mount_points())
...@@ -137,10 +131,6 @@ void MockDiskMountManager::NotifyMountEvent(MountEvent event, ...@@ -137,10 +131,6 @@ void MockDiskMountManager::NotifyMountEvent(MountEvent event,
} }
void MockDiskMountManager::SetupDefaultReplies() { void MockDiskMountManager::SetupDefaultReplies() {
EXPECT_CALL(*this, AddObserver(_))
.Times(AnyNumber());
EXPECT_CALL(*this, RemoveObserver(_))
.Times(AnyNumber());
EXPECT_CALL(*this, disks()) EXPECT_CALL(*this, disks())
.WillRepeatedly(ReturnRef(disks_)); .WillRepeatedly(ReturnRef(disks_));
EXPECT_CALL(*this, mount_points()) EXPECT_CALL(*this, mount_points())
......
...@@ -28,8 +28,8 @@ class MockDiskMountManager : public DiskMountManager { ...@@ -28,8 +28,8 @@ class MockDiskMountManager : public DiskMountManager {
// DiskMountManager override. // DiskMountManager override.
MOCK_METHOD0(Init, void(void)); MOCK_METHOD0(Init, void(void));
MOCK_METHOD1(AddObserver, void(DiskMountManager::Observer*)); void AddObserver(DiskMountManager::Observer*) override;
MOCK_METHOD1(RemoveObserver, void(DiskMountManager::Observer*)); void RemoveObserver(DiskMountManager::Observer*) override;
MOCK_CONST_METHOD0(disks, const DiskMountManager::DiskMap&(void)); MOCK_CONST_METHOD0(disks, const DiskMountManager::DiskMap&(void));
MOCK_CONST_METHOD1(FindDiskBySourcePath, const Disk*(const std::string&)); MOCK_CONST_METHOD1(FindDiskBySourcePath, const Disk*(const std::string&));
MOCK_CONST_METHOD0(mount_points, MOCK_CONST_METHOD0(mount_points,
......
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