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