This source file includes following definitions.
- OnFileSystemMounted
- Wait
- WaitUntilDriveMountPointIsAdded
#include "chrome/browser/chromeos/file_manager/drive_test_util.h"
#include "base/files/file_path.h"
#include "base/run_loop.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "webkit/browser/fileapi/external_mount_points.h"
namespace file_manager {
namespace test_util {
namespace {
class DriveMountPointWaiter : public drive::DriveIntegrationServiceObserver {
public:
explicit DriveMountPointWaiter(
drive::DriveIntegrationService* integration_service)
: integration_service_(integration_service) {
integration_service_->AddObserver(this);
}
virtual ~DriveMountPointWaiter() {
integration_service_->RemoveObserver(this);
}
virtual void OnFileSystemMounted() OVERRIDE {
run_loop_.Quit();
}
void Wait() {
run_loop_.Run();
}
private:
drive::DriveIntegrationService* integration_service_;
base::RunLoop run_loop_;
};
}
void WaitUntilDriveMountPointIsAdded(Profile* profile) {
DCHECK(profile);
drive::DriveIntegrationService* integration_service =
drive::DriveIntegrationServiceFactory::FindForProfileRegardlessOfStates(
profile);
DCHECK(integration_service);
DCHECK(integration_service->is_enabled());
if (integration_service->IsMounted())
return;
DriveMountPointWaiter mount_point_waiter(integration_service);
VLOG(1) << "Waiting for drive mount point to get mounted.";
mount_point_waiter.Wait();
VLOG(1) << "Drive mount point found.";
}
}
}