Commit 1f326d0c authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

Drive: Adds clearDriveCache API to file_browser_private.

This API is to clear all the local cache of Drive.

BUG=135197
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10837091

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149949 0039d316-1c4b-4281-b951-d872f2087c98
parent f81fd4df
...@@ -2365,6 +2365,21 @@ void SearchDriveFunction::OnSearch( ...@@ -2365,6 +2365,21 @@ void SearchDriveFunction::OnSearch(
SendResponse(true); SendResponse(true);
} }
bool ClearDriveCacheFunction::RunImpl() {
gdata::GDataSystemService* system_service =
gdata::GDataSystemServiceFactory::GetForProfile(profile_);
// |system_service| is NULL if incognito window / guest login.
if (!system_service || !system_service->file_system())
return false;
// TODO(yoshiki): Receive a callback from JS-side and pass it to
// ClearCacheAndRemountFileSystem(). http://crbug.com/140511
system_service->ClearCacheAndRemountFileSystem(base::Callback<void(bool)>());
SendResponse(true);
return true;
}
bool GetNetworkConnectionStateFunction::RunImpl() { bool GetNetworkConnectionStateFunction::RunImpl() {
chromeos::NetworkLibrary* network_library = chromeos::NetworkLibrary* network_library =
chromeos::CrosLibrary::Get()->GetNetworkLibrary(); chromeos::CrosLibrary::Get()->GetNetworkLibrary();
......
...@@ -670,6 +670,16 @@ class SearchDriveFunction : public AsyncExtensionFunction { ...@@ -670,6 +670,16 @@ class SearchDriveFunction : public AsyncExtensionFunction {
GURL file_system_url_; GURL file_system_url_;
}; };
class ClearDriveCacheFunction : public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.clearDriveCache");
protected:
virtual ~ClearDriveCacheFunction() {}
virtual bool RunImpl() OVERRIDE;
};
// Implements the chrome.fileBrowserPrivate.getNetworkConnectionState method. // Implements the chrome.fileBrowserPrivate.getNetworkConnectionState method.
class GetNetworkConnectionStateFunction : public SyncExtensionFunction { class GetNetworkConnectionStateFunction : public SyncExtensionFunction {
public: public:
......
...@@ -376,6 +376,7 @@ void ExtensionFunctionRegistry::ResetFunctions() { ...@@ -376,6 +376,7 @@ void ExtensionFunctionRegistry::ResetFunctions() {
RegisterFunction<GetGDataPreferencesFunction>(); RegisterFunction<GetGDataPreferencesFunction>();
RegisterFunction<SetGDataPreferencesFunction>(); RegisterFunction<SetGDataPreferencesFunction>();
RegisterFunction<SearchDriveFunction>(); RegisterFunction<SearchDriveFunction>();
RegisterFunction<ClearDriveCacheFunction>();
RegisterFunction<GetNetworkConnectionStateFunction>(); RegisterFunction<GetNetworkConnectionStateFunction>();
RegisterFunction<RequestDirectoryRefreshFunction>(); RegisterFunction<RequestDirectoryRefreshFunction>();
......
...@@ -944,6 +944,11 @@ ...@@ -944,6 +944,11 @@
} }
] ]
}, },
{
"name": "clearDriveCache",
"description": "Clear all GData local caches.",
"parameters": []
},
{ {
"name": "getNetworkConnectionState", "name": "getNetworkConnectionState",
"description": "Retrieves the state of the currently active network connection.", "description": "Retrieves the state of the currently active network connection.",
......
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