Commit 78a1a330 authored by satorux@chromium.org's avatar satorux@chromium.org

gdata: Remove hide_hosted_documents from ReadDirectoryCallback

Background: We plan to Add ReadDirectoryByPath() to GDataDirectoryService
and use the same ReadDirectoryCallback, and hide_hosted_documents  turned
out to be an obstacle. It's cleaner to check the setting in the caller,
where this setting matters anyway.

BUG=141147
TEST=confirm that the "show hosted documents" setting works as before

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150436 0039d316-1c4b-4281-b951-d872f2087c98
parent 48d75208
...@@ -516,7 +516,6 @@ GDataFileSystem::GDataFileSystem( ...@@ -516,7 +516,6 @@ GDataFileSystem::GDataFileSystem(
documents_service_(documents_service), documents_service_(documents_service),
webapps_registry_(webapps_registry), webapps_registry_(webapps_registry),
update_timer_(true /* retain_user_task */, true /* is_repeating */), update_timer_(true /* retain_user_task */, true /* is_repeating */),
hide_hosted_docs_(false),
blocking_task_runner_(blocking_task_runner), blocking_task_runner_(blocking_task_runner),
ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
ui_weak_ptr_(ui_weak_ptr_factory_.GetWeakPtr()) { ui_weak_ptr_(ui_weak_ptr_factory_.GetWeakPtr()) {
...@@ -537,9 +536,6 @@ void GDataFileSystem::Initialize() { ...@@ -537,9 +536,6 @@ void GDataFileSystem::Initialize() {
blocking_task_runner_)); blocking_task_runner_));
feed_loader_->AddObserver(this); feed_loader_->AddObserver(this);
PrefService* pref_service = profile_->GetPrefs();
hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableGDataHostedFiles);
InitializePreferenceObserver(); InitializePreferenceObserver();
} }
...@@ -1866,7 +1862,6 @@ void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback, ...@@ -1866,7 +1862,6 @@ void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback,
if (error != GDATA_FILE_OK) { if (error != GDATA_FILE_OK) {
if (!callback.is_null()) if (!callback.is_null())
callback.Run(error, callback.Run(error,
hide_hosted_docs_,
scoped_ptr<GDataEntryProtoVector>()); scoped_ptr<GDataEntryProtoVector>());
return; return;
} }
...@@ -1876,7 +1871,6 @@ void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback, ...@@ -1876,7 +1871,6 @@ void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback,
if (!directory) { if (!directory) {
if (!callback.is_null()) if (!callback.is_null())
callback.Run(GDATA_FILE_ERROR_NOT_FOUND, callback.Run(GDATA_FILE_ERROR_NOT_FOUND,
hide_hosted_docs_,
scoped_ptr<GDataEntryProtoVector>()); scoped_ptr<GDataEntryProtoVector>());
return; return;
} }
...@@ -1898,7 +1892,7 @@ void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback, ...@@ -1898,7 +1892,7 @@ void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback,
} }
if (!callback.is_null()) if (!callback.is_null())
callback.Run(GDATA_FILE_OK, hide_hosted_docs_, entries.Pass()); callback.Run(GDATA_FILE_OK, entries.Pass());
} }
void GDataFileSystem::RequestDirectoryRefresh(const FilePath& file_path) { void GDataFileSystem::RequestDirectoryRefresh(const FilePath& file_path) {
...@@ -2971,31 +2965,18 @@ void GDataFileSystem::Observe(int type, ...@@ -2971,31 +2965,18 @@ void GDataFileSystem::Observe(int type,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (type == chrome::NOTIFICATION_PREF_CHANGED) { if (type == chrome::NOTIFICATION_PREF_CHANGED) {
PrefService* pref_service = profile_->GetPrefs();
std::string* pref_name = content::Details<std::string>(details).ptr(); std::string* pref_name = content::Details<std::string>(details).ptr();
if (*pref_name == prefs::kDisableGDataHostedFiles) { if (*pref_name == prefs::kDisableGDataHostedFiles) {
SetHideHostedDocuments( const FilePath root_path = directory_service_->root()->GetFilePath();
pref_service->GetBoolean(prefs::kDisableGDataHostedFiles)); // Kick off directory refresh when this setting changes.
FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
OnDirectoryChanged(root_path));
} }
} else { } else {
NOTREACHED(); NOTREACHED();
} }
} }
void GDataFileSystem::SetHideHostedDocuments(bool hide) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (hide == hide_hosted_docs_)
return;
hide_hosted_docs_ = hide;
const FilePath root_path = directory_service_->root()->GetFilePath();
// Kick off directory refresh when this setting changes.
FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
OnDirectoryChanged(root_path));
}
//============= GDataFileSystem: internal helper functions ===================== //============= GDataFileSystem: internal helper functions =====================
void GDataFileSystem::InitializePreferenceObserver() { void GDataFileSystem::InitializePreferenceObserver() {
......
...@@ -600,9 +600,6 @@ class GDataFileSystem : public GDataFileSystemInterface, ...@@ -600,9 +600,6 @@ class GDataFileSystem : public GDataFileSystemInterface,
void FindEntryByPathSyncOnUIThread(const FilePath& search_file_path, void FindEntryByPathSyncOnUIThread(const FilePath& search_file_path,
const FindEntryCallback& callback); const FindEntryCallback& callback);
// Changes state of hosted documents visibility, triggers directory refresh.
void SetHideHostedDocuments(bool hide);
// Initializes preference change observer. // Initializes preference change observer.
void InitializePreferenceObserver(); void InitializePreferenceObserver();
...@@ -797,9 +794,6 @@ class GDataFileSystem : public GDataFileSystemInterface, ...@@ -797,9 +794,6 @@ class GDataFileSystem : public GDataFileSystemInterface,
// Periodic timer for checking updates. // Periodic timer for checking updates.
base::Timer update_timer_; base::Timer update_timer_;
// True if hosted documents should be hidden.
bool hide_hosted_docs_;
// The set of paths opened by OpenFile but not yet closed by CloseFile. // The set of paths opened by OpenFile but not yet closed by CloseFile.
std::set<FilePath> open_files_; std::set<FilePath> open_files_;
......
...@@ -62,7 +62,6 @@ typedef base::Callback<void(GDataFileError error, ...@@ -62,7 +62,6 @@ typedef base::Callback<void(GDataFileError error,
// |entries| are contents, both files and directories, of the directory. // |entries| are contents, both files and directories, of the directory.
typedef std::vector<GDataEntryProto> GDataEntryProtoVector; typedef std::vector<GDataEntryProto> GDataEntryProtoVector;
typedef base::Callback<void(GDataFileError error, typedef base::Callback<void(GDataFileError error,
bool hide_hosted_documents,
scoped_ptr<GDataEntryProtoVector> entries)> scoped_ptr<GDataEntryProtoVector> entries)>
ReadDirectoryCallback; ReadDirectoryCallback;
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h"
#include "chrome/browser/chromeos/gdata/gdata_system_service.h" #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
#include "chrome/browser/chromeos/gdata/gdata_util.h" #include "chrome/browser/chromeos/gdata/gdata_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "webkit/blob/shareable_file_reference.h" #include "webkit/blob/shareable_file_reference.h"
#include "webkit/fileapi/file_system_file_util_proxy.h" #include "webkit/fileapi/file_system_file_util_proxy.h"
...@@ -177,8 +180,10 @@ base::FileUtilProxy::Entry GDataEntryProtoToFileUtilProxyEntry( ...@@ -177,8 +180,10 @@ base::FileUtilProxy::Entry GDataEntryProtoToFileUtilProxyEntry(
// GDataFileSystemProxy class implementation. // GDataFileSystemProxy class implementation.
GDataFileSystemProxy::GDataFileSystemProxy( GDataFileSystemProxy::GDataFileSystemProxy(
GDataFileSystemInterface* file_system) GDataFileSystemInterface* file_system,
: file_system_(file_system) { Profile* profile)
: file_system_(file_system),
profile_(profile) {
// Should be created from the file browser extension API (AddMountFunction) // Should be created from the file browser extension API (AddMountFunction)
// on UI thread. // on UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
...@@ -676,10 +681,13 @@ void GDataFileSystemProxy::OnReadDirectory( ...@@ -676,10 +681,13 @@ void GDataFileSystemProxy::OnReadDirectory(
const FileSystemOperationInterface::ReadDirectoryCallback& const FileSystemOperationInterface::ReadDirectoryCallback&
callback, callback,
GDataFileError error, GDataFileError error,
bool hide_hosted_documents,
scoped_ptr<gdata::GDataEntryProtoVector> proto_entries) { scoped_ptr<gdata::GDataEntryProtoVector> proto_entries) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
PrefService* pref_service = profile_->GetPrefs();
const bool hide_hosted_documents =
pref_service->GetBoolean(prefs::kDisableGDataHostedFiles);
if (error != GDATA_FILE_OK) { if (error != GDATA_FILE_OK) {
callback.Run(util::GDataFileErrorToPlatformError(error), callback.Run(util::GDataFileErrorToPlatformError(error),
std::vector<base::FileUtilProxy::Entry>(), std::vector<base::FileUtilProxy::Entry>(),
......
...@@ -13,6 +13,8 @@ namespace fileapi { ...@@ -13,6 +13,8 @@ namespace fileapi {
class FileSystemURL; class FileSystemURL;
} }
class Profile;
namespace gdata { namespace gdata {
class GDataEntryProto; class GDataEntryProto;
...@@ -22,7 +24,8 @@ class GDataFileSystemInterface; ...@@ -22,7 +24,8 @@ class GDataFileSystemInterface;
class GDataFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { class GDataFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface {
public: public:
// |file_system| is the GDataFileSystem instance owned by GDataSystemService. // |file_system| is the GDataFileSystem instance owned by GDataSystemService.
explicit GDataFileSystemProxy(GDataFileSystemInterface* file_system); explicit GDataFileSystemProxy(GDataFileSystemInterface* file_system,
Profile* profile);
// fileapi::RemoteFileSystemProxyInterface overrides. // fileapi::RemoteFileSystemProxyInterface overrides.
virtual void GetFileInfo( virtual void GetFileInfo(
...@@ -117,7 +120,6 @@ class GDataFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { ...@@ -117,7 +120,6 @@ class GDataFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface {
const fileapi::FileSystemOperationInterface::ReadDirectoryCallback& const fileapi::FileSystemOperationInterface::ReadDirectoryCallback&
callback, callback,
GDataFileError error, GDataFileError error,
bool hide_hosted_documents,
scoped_ptr<gdata::GDataEntryProtoVector> proto_entries); scoped_ptr<gdata::GDataEntryProtoVector> proto_entries);
// Helper callback for relaying reply for CreateWritableSnapshotFile() to // Helper callback for relaying reply for CreateWritableSnapshotFile() to
...@@ -183,6 +185,9 @@ class GDataFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface { ...@@ -183,6 +185,9 @@ class GDataFileSystemProxy : public fileapi::RemoteFileSystemProxyInterface {
// removed, the file manager is already gone). Hence it's safe to use this as // removed, the file manager is already gone). Hence it's safe to use this as
// a raw pointer. // a raw pointer.
GDataFileSystemInterface* file_system_; GDataFileSystemInterface* file_system_;
// Profile associated with the file system proxy.
Profile* profile_; // Not owned.
}; };
} // namespace chromeos } // namespace chromeos
......
...@@ -803,7 +803,6 @@ class GDataFileSystemTest : public testing::Test { ...@@ -803,7 +803,6 @@ class GDataFileSystemTest : public testing::Test {
virtual void ReadDirectoryCallback( virtual void ReadDirectoryCallback(
GDataFileError error, GDataFileError error,
bool /* hide_hosted_documents */,
scoped_ptr<GDataEntryProtoVector> entries) { scoped_ptr<GDataEntryProtoVector> entries) {
last_error_ = error; last_error_ = error;
directory_entries_ = entries.Pass(); directory_entries_ = entries.Pass();
......
...@@ -141,7 +141,7 @@ void GDataSystemService::AddDriveMountPoint() { ...@@ -141,7 +141,7 @@ void GDataSystemService::AddDriveMountPoint() {
if (provider && !provider->HasMountPoint(mount_point)) { if (provider && !provider->HasMountPoint(mount_point)) {
provider->AddRemoteMountPoint( provider->AddRemoteMountPoint(
mount_point, mount_point,
new GDataFileSystemProxy(file_system_.get())); new GDataFileSystemProxy(file_system_.get(), profile_));
} }
file_system_->Initialize(); file_system_->Initialize();
......
...@@ -170,7 +170,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -170,7 +170,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
// Called when ReadDirectoryByPath() is complete. // Called when ReadDirectoryByPath() is complete.
void OnReadDirectoryByPath(const FilePath& parent_path, void OnReadDirectoryByPath(const FilePath& parent_path,
gdata::GDataFileError error, gdata::GDataFileError error,
bool hide_hosted_documents,
scoped_ptr<gdata::GDataEntryProtoVector> entries); scoped_ptr<gdata::GDataEntryProtoVector> entries);
// Called when GetResourceIdsOfAllFilesOnUIThread() is complete. // Called when GetResourceIdsOfAllFilesOnUIThread() is complete.
...@@ -263,7 +262,6 @@ void DriveInternalsWebUIHandler::OnGetGCacheContents( ...@@ -263,7 +262,6 @@ void DriveInternalsWebUIHandler::OnGetGCacheContents(
void DriveInternalsWebUIHandler::OnReadDirectoryByPath( void DriveInternalsWebUIHandler::OnReadDirectoryByPath(
const FilePath& parent_path, const FilePath& parent_path,
gdata::GDataFileError error, gdata::GDataFileError error,
bool hide_hosted_documents,
scoped_ptr<gdata::GDataEntryProtoVector> entries) { scoped_ptr<gdata::GDataEntryProtoVector> entries) {
--num_pending_reads_; --num_pending_reads_;
if (error == gdata::GDATA_FILE_OK) { if (error == gdata::GDATA_FILE_OK) {
......
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