summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/gdata
diff options
context:
space:
mode:
authormtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 04:48:01 +0000
committermtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 04:48:01 +0000
commita0927550607ce907dd4733ff94d9671d0598d7ec (patch)
tree872366d34a48eaca042e61e31272e3abba489f06 /chrome/browser/chromeos/gdata
parent11387d28032c36724cfe108c544b639c33a6109a (diff)
downloadchromium_src-a0927550607ce907dd4733ff94d9671d0598d7ec.zip
chromium_src-a0927550607ce907dd4733ff94d9671d0598d7ec.tar.gz
chromium_src-a0927550607ce907dd4733ff94d9671d0598d7ec.tar.bz2
Externalized observer classes in gdata files.
Formerly nested observer classes are now refactored to top-level classes in separate files. Therefore, now to implement an observer we need to include only the *_observer.h file. OperationRegistryObserver has not been moved to separate file because it uses another nested structures. Also, redundant includes were removed and changed into required forward declarations. BUG=141261 TEST=unit_tests Review URL: https://chromiumcodereview.appspot.com/10914191 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/gdata')
-rw-r--r--chrome/browser/chromeos/gdata/drive_api_service.h5
-rw-r--r--chrome/browser/chromeos/gdata/drive_cache.cc17
-rw-r--r--chrome/browser/chromeos/gdata/drive_cache.h25
-rw-r--r--chrome/browser/chromeos/gdata/drive_cache_observer.h33
-rw-r--r--chrome/browser/chromeos/gdata/drive_file_system.cc25
-rw-r--r--chrome/browser/chromeos/gdata/drive_file_system.h18
-rw-r--r--chrome/browser/chromeos/gdata/drive_file_system_interface.h33
-rw-r--r--chrome/browser/chromeos/gdata/drive_file_system_observer.h52
-rw-r--r--chrome/browser/chromeos/gdata/drive_sync_client.cc1
-rw-r--r--chrome/browser/chromeos/gdata/drive_sync_client.h11
-rw-r--r--chrome/browser/chromeos/gdata/drive_task_executor.cc1
-rw-r--r--chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc18
-rw-r--r--chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h27
-rw-r--r--chrome/browser/chromeos/gdata/gdata_wapi_feed_loader_observer.h39
-rw-r--r--chrome/browser/chromeos/gdata/gdata_wapi_service.cc1
-rw-r--r--chrome/browser/chromeos/gdata/gdata_wapi_service.h7
-rw-r--r--chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc1
-rw-r--r--chrome/browser/chromeos/gdata/mock_directory_change_observer.h5
-rw-r--r--chrome/browser/chromeos/gdata/mock_drive_cache_observer.h4
-rw-r--r--chrome/browser/chromeos/gdata/mock_drive_file_system.h7
-rw-r--r--chrome/browser/chromeos/gdata/stale_cache_files_remover.h12
21 files changed, 218 insertions, 124 deletions
diff --git a/chrome/browser/chromeos/gdata/drive_api_service.h b/chrome/browser/chromeos/gdata/drive_api_service.h
index ecc7bd8..bf30702 100644
--- a/chrome/browser/chromeos/gdata/drive_api_service.h
+++ b/chrome/browser/chromeos/gdata/drive_api_service.h
@@ -11,6 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/gdata/drive_service_interface.h"
#include "chrome/browser/google_apis/auth_service.h"
+#include "chrome/browser/google_apis/auth_service_observer.h"
#include "chrome/browser/google_apis/gdata_operations.h"
class FilePath;
@@ -25,8 +26,8 @@ class OperationRunner;
// Details of API call are abstracted in each operation class and this class
// works as a thin wrapper for the API.
class DriveAPIService : public DriveServiceInterface,
- public AuthService::Observer,
- public OperationRegistry::Observer {
+ public AuthServiceObserver,
+ public OperationRegistryObserver {
public:
// Instance is usually created by DriveSystemServiceFactory and owned by
// DriveFileSystem.
diff --git a/chrome/browser/chromeos/gdata/drive_cache.cc b/chrome/browser/chromeos/gdata/drive_cache.cc
index 3b34ff4..174cf30 100644
--- a/chrome/browser/chromeos/gdata/drive_cache.cc
+++ b/chrome/browser/chromeos/gdata/drive_cache.cc
@@ -14,6 +14,7 @@
#include "base/sys_info.h"
#include "chrome/browser/chromeos/gdata/drive.pb.h"
#include "chrome/browser/chromeos/gdata/drive_cache_metadata.h"
+#include "chrome/browser/chromeos/gdata/drive_cache_observer.h"
#include "chrome/browser/chromeos/gdata/drive_file_system_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
@@ -373,12 +374,12 @@ bool DriveCache::IsUnderDriveCacheDirectory(const FilePath& path) const {
return cache_root_path_ == path || cache_root_path_.IsParent(path);
}
-void DriveCache::AddObserver(Observer* observer) {
+void DriveCache::AddObserver(DriveCacheObserver* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observers_.AddObserver(observer);
}
-void DriveCache::RemoveObserver(Observer* observer) {
+void DriveCache::RemoveObserver(DriveCacheObserver* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observers_.RemoveObserver(observer);
}
@@ -1513,7 +1514,9 @@ void DriveCache::OnPinned(DriveFileError* error,
callback.Run(*error, resource_id, md5);
if (*error == DRIVE_FILE_OK)
- FOR_EACH_OBSERVER(Observer, observers_, OnCachePinned(resource_id, md5));
+ FOR_EACH_OBSERVER(DriveCacheObserver,
+ observers_,
+ OnCachePinned(resource_id, md5));
}
void DriveCache::OnUnpinned(DriveFileError* error,
@@ -1527,7 +1530,9 @@ void DriveCache::OnUnpinned(DriveFileError* error,
callback.Run(*error, resource_id, md5);
if (*error == DRIVE_FILE_OK)
- FOR_EACH_OBSERVER(Observer, observers_, OnCacheUnpinned(resource_id, md5));
+ FOR_EACH_OBSERVER(DriveCacheObserver,
+ observers_,
+ OnCacheUnpinned(resource_id, md5));
// Now the file is moved from "persistent" to "tmp" directory.
// It's a chance to free up space if needed.
@@ -1551,7 +1556,9 @@ void DriveCache::OnCommitDirty(DriveFileError* error,
callback.Run(*error, resource_id, md5);
if (*error == DRIVE_FILE_OK)
- FOR_EACH_OBSERVER(Observer, observers_, OnCacheCommitted(resource_id));
+ FOR_EACH_OBSERVER(DriveCacheObserver,
+ observers_,
+ OnCacheCommitted(resource_id));
}
void DriveCache::GetCacheEntryHelper(const std::string& resource_id,
diff --git a/chrome/browser/chromeos/gdata/drive_cache.h b/chrome/browser/chromeos/gdata/drive_cache.h
index 19fd4cc..17bc6fc 100644
--- a/chrome/browser/chromeos/gdata/drive_cache.h
+++ b/chrome/browser/chromeos/gdata/drive_cache.h
@@ -27,6 +27,7 @@ namespace gdata {
class DriveCacheEntry;
class DriveCacheMetadata;
+class DriveCacheObserver;
// Callback for SetMountedStateOnUIThread and ClearAllOnUIThread.
typedef base::Callback<void(DriveFileError error,
@@ -109,24 +110,6 @@ class DriveCache {
FILE_OPERATION_COPY,
};
- // Used to notify events. All events are notified on UI thread.
- class Observer {
- public:
- // Triggered when a file has been pinned successfully.
- virtual void OnCachePinned(const std::string& resource_id,
- const std::string& md5) {}
-
- // Triggered when a file has been unpinned successfully.
- virtual void OnCacheUnpinned(const std::string& resource_id,
- const std::string& md5) {}
-
- // Triggered when a dirty file has been committed (saved) successfully.
- virtual void OnCacheCommitted(const std::string& resource_id) {}
-
- protected:
- virtual ~Observer() {}
- };
-
// Returns the sub-directory under drive cache directory for the given sub
// directory type. Example: <user_profile_dir>/GCache/v1/tmp
//
@@ -149,11 +132,11 @@ class DriveCache {
// Adds observer.
// Must be called on UI thread.
- void AddObserver(Observer* observer);
+ void AddObserver(DriveCacheObserver* observer);
// Removes observer.
// Must be called on UI thread.
- void RemoveObserver(Observer* observer);
+ void RemoveObserver(DriveCacheObserver* observer);
// Gets the cache entry by the given resource ID and MD5.
// See also GetCacheEntry().
@@ -452,7 +435,7 @@ class DriveCache {
scoped_ptr<DriveCacheMetadata> metadata_;
// List of observers, this member must be accessed on UI thread.
- ObserverList<Observer> observers_;
+ ObserverList<DriveCacheObserver> observers_;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
diff --git a/chrome/browser/chromeos/gdata/drive_cache_observer.h b/chrome/browser/chromeos/gdata/drive_cache_observer.h
new file mode 100644
index 0000000..ef95dec
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/drive_cache_observer.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_OBSERVER_H_
+
+#include <string>
+
+namespace gdata {
+
+// Interface for classes that need to observe events from DriveCache.
+// All events are notified on UI thread.
+class DriveCacheObserver {
+ public:
+ // Triggered when a file has been pinned successfully.
+ virtual void OnCachePinned(const std::string& resource_id,
+ const std::string& md5) {}
+
+ // Triggered when a file has been unpinned successfully.
+ virtual void OnCacheUnpinned(const std::string& resource_id,
+ const std::string& md5) {}
+
+ // Triggered when a dirty file has been committed (saved) successfully.
+ virtual void OnCacheCommitted(const std::string& resource_id) {}
+
+ protected:
+ virtual ~DriveCacheObserver() {}
+};
+
+} // namespace gdata
+
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_OBSERVER_H_
diff --git a/chrome/browser/chromeos/gdata/drive_file_system.cc b/chrome/browser/chromeos/gdata/drive_file_system.cc
index db2ef6b..a4505d8 100644
--- a/chrome/browser/chromeos/gdata/drive_file_system.cc
+++ b/chrome/browser/chromeos/gdata/drive_file_system.cc
@@ -16,11 +16,13 @@
#include "chrome/browser/api/prefs/pref_change_registrar.h"
#include "chrome/browser/chromeos/gdata/drive.pb.h"
#include "chrome/browser/chromeos/gdata/drive_files.h"
+#include "chrome/browser/chromeos/gdata/drive_file_system_observer.h"
#include "chrome/browser/chromeos/gdata/drive_file_system_util.h"
#include "chrome/browser/chromeos/gdata/drive_function_remove.h"
#include "chrome/browser/chromeos/gdata/drive_scheduler.h"
#include "chrome/browser/chromeos/gdata/drive_service_interface.h"
#include "chrome/browser/chromeos/gdata/drive_uploader.h"
+#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h"
#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h"
#include "chrome/browser/google_apis/drive_api_parser.h"
#include "chrome/browser/google_apis/gdata_util.h"
@@ -101,7 +103,7 @@ void OnAddUploadFileCompleted(
// The class to wait for the initial load of root feed and runs the callback
// after the initialization.
-class InitialLoadObserver : public DriveFileSystemInterface::Observer {
+class InitialLoadObserver : public DriveFileSystemObserver {
public:
InitialLoadObserver(DriveFileSystemInterface* file_system,
const FileOperationCallback& callback)
@@ -515,14 +517,12 @@ DriveFileSystem::~DriveFileSystem() {
drive_service_->CancelAll();
}
-void DriveFileSystem::AddObserver(
- DriveFileSystemInterface::Observer* observer) {
+void DriveFileSystem::AddObserver(DriveFileSystemObserver* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observers_.AddObserver(observer);
}
-void DriveFileSystem::RemoveObserver(
- DriveFileSystemInterface::Observer* observer) {
+void DriveFileSystem::RemoveObserver(DriveFileSystemObserver* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observers_.RemoveObserver(observer);
}
@@ -2338,21 +2338,21 @@ void DriveFileSystem::SearchAsyncOnUIThread(
void DriveFileSystem::OnDirectoryChanged(const FilePath& directory_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- FOR_EACH_OBSERVER(DriveFileSystemInterface::Observer, observers_,
+ FOR_EACH_OBSERVER(DriveFileSystemObserver, observers_,
OnDirectoryChanged(directory_path));
}
void DriveFileSystem::OnDocumentFeedFetched(int num_accumulated_entries) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- FOR_EACH_OBSERVER(DriveFileSystemInterface::Observer, observers_,
+ FOR_EACH_OBSERVER(DriveFileSystemObserver, observers_,
OnDocumentFeedFetched(num_accumulated_entries));
}
void DriveFileSystem::OnFeedFromServerLoaded() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- FOR_EACH_OBSERVER(DriveFileSystemInterface::Observer, observers_,
+ FOR_EACH_OBSERVER(DriveFileSystemObserver, observers_,
OnFeedFromServerLoaded());
}
@@ -2598,7 +2598,7 @@ void DriveFileSystem::NotifyFileSystemMounted() {
DVLOG(1) << "File System is mounted";
// Notify the observers that the file system is mounted.
- FOR_EACH_OBSERVER(DriveFileSystemInterface::Observer, observers_,
+ FOR_EACH_OBSERVER(DriveFileSystemObserver, observers_,
OnFileSystemMounted());
}
@@ -2607,7 +2607,7 @@ void DriveFileSystem::NotifyFileSystemToBeUnmounted() {
DVLOG(1) << "File System is to be unmounted";
// Notify the observers that the file system is being unmounted.
- FOR_EACH_OBSERVER(DriveFileSystemInterface::Observer, observers_,
+ FOR_EACH_OBSERVER(DriveFileSystemObserver, observers_,
OnFileSystemBeingUnmounted());
}
@@ -2621,7 +2621,8 @@ void DriveFileSystem::NotifyInitialLoadFinishedAndRun(
resource_metadata_->set_origin(UNINITIALIZED);
// Notify the observers that root directory has been initialized.
- FOR_EACH_OBSERVER(DriveFileSystemInterface::Observer, observers_,
+ FOR_EACH_OBSERVER(DriveFileSystemObserver,
+ observers_,
OnInitialLoadFinished(error));
callback.Run(error);
@@ -2898,7 +2899,7 @@ void DriveFileSystem::SetHideHostedDocuments(bool hide) {
const FilePath root_path = resource_metadata_->root()->GetFilePath();
// Kick off directory refresh when this setting changes.
- FOR_EACH_OBSERVER(DriveFileSystemInterface::Observer, observers_,
+ FOR_EACH_OBSERVER(DriveFileSystemObserver, observers_,
OnDirectoryChanged(root_path));
}
diff --git a/chrome/browser/chromeos/gdata/drive_file_system.h b/chrome/browser/chromeos/gdata/drive_file_system.h
index 5f83d23..8cb9f9c 100644
--- a/chrome/browser/chromeos/gdata/drive_file_system.h
+++ b/chrome/browser/chromeos/gdata/drive_file_system.h
@@ -14,7 +14,7 @@
#include "base/timer.h"
#include "chrome/browser/chromeos/gdata/drive_cache.h"
#include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
-#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h"
+#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader_observer.h"
#include "chrome/browser/google_apis/gdata_errorcode.h"
#include "content/public/browser/notification_observer.h"
@@ -27,16 +27,20 @@ class SequencedTaskRunner;
namespace gdata {
+class DocumentFeed;
+class DriveFileSystemObserver;
class DriveFunctionRemove;
class DriveResourceMetadata;
class DriveServiceInterface;
+class DriveScheduler;
class DriveUploaderInterface;
class DriveWebAppsRegistryInterface;
-class DriveScheduler;
+class GDataWapiFeedLoader;
+struct LoadFeedParams;
// The production implementation of DriveFileSystemInterface.
class DriveFileSystem : public DriveFileSystemInterface,
- public GDataWapiFeedLoader::Observer,
+ public GDataWapiFeedLoaderObserver,
public content::NotificationObserver {
public:
DriveFileSystem(Profile* profile,
@@ -49,10 +53,8 @@ class DriveFileSystem : public DriveFileSystemInterface,
// DriveFileSystem overrides.
virtual void Initialize() OVERRIDE;
- virtual void AddObserver(
- DriveFileSystemInterface::Observer* observer) OVERRIDE;
- virtual void RemoveObserver(
- DriveFileSystemInterface::Observer* observer) OVERRIDE;
+ virtual void AddObserver(DriveFileSystemObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(DriveFileSystemObserver* observer) OVERRIDE;
virtual void StartInitialFeedFetch() OVERRIDE;
virtual void StartUpdates() OVERRIDE;
virtual void StopUpdates() OVERRIDE;
@@ -922,7 +924,7 @@ class DriveFileSystem : public DriveFileSystemInterface,
// The loader is used to load the feeds.
scoped_ptr<GDataWapiFeedLoader> feed_loader_;
- ObserverList<DriveFileSystemInterface::Observer> observers_;
+ ObserverList<DriveFileSystemObserver> observers_;
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
diff --git a/chrome/browser/chromeos/gdata/drive_file_system_interface.h b/chrome/browser/chromeos/gdata/drive_file_system_interface.h
index d89a850..80e86c9 100644
--- a/chrome/browser/chromeos/gdata/drive_file_system_interface.h
+++ b/chrome/browser/chromeos/gdata/drive_file_system_interface.h
@@ -17,6 +17,7 @@ namespace gdata {
class DocumentEntry;
class DriveEntryProto;
+class DriveFileSystemObserver;
typedef std::vector<DriveEntryProto> DriveEntryProtoVector;
@@ -72,41 +73,13 @@ class DriveFileSystemInterface {
public:
virtual ~DriveFileSystemInterface() {}
- // Used to notify events on the file system.
- // All events are notified on UI thread.
- class Observer {
- public:
- // Triggered when a content of a directory has been changed.
- // |directory_path| is a virtual directory path (/drive/...) representing
- // changed directory.
- virtual void OnDirectoryChanged(const FilePath& directory_path) {}
-
- // Triggered when the file system is initially loaded.
- virtual void OnInitialLoadFinished(DriveFileError error) {}
-
- // Triggered when a document feed is fetched. |num_accumulated_entries|
- // tells the number of entries fetched so far.
- virtual void OnDocumentFeedFetched(int num_accumulated_entries) {}
-
- // Triggered when the feed from the server is loaded.
- virtual void OnFeedFromServerLoaded() {}
-
- // Triggered when the file system is mounted.
- virtual void OnFileSystemMounted() {}
- // Triggered when the file system is being unmounted.
- virtual void OnFileSystemBeingUnmounted() {}
-
- protected:
- virtual ~Observer() {}
- };
-
// Initializes the object. This function should be called before any
// other functions.
virtual void Initialize() = 0;
// Adds and removes the observer.
- virtual void AddObserver(Observer* observer) = 0;
- virtual void RemoveObserver(Observer* observer) = 0;
+ virtual void AddObserver(DriveFileSystemObserver* observer) = 0;
+ virtual void RemoveObserver(DriveFileSystemObserver* observer) = 0;
// Starts initial feed fetch from the server.
virtual void StartInitialFeedFetch() = 0;
diff --git a/chrome/browser/chromeos/gdata/drive_file_system_observer.h b/chrome/browser/chromeos/gdata/drive_file_system_observer.h
new file mode 100644
index 0000000..a2b116e
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/drive_file_system_observer.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_OBSERVER_H_
+
+#include "chrome/browser/google_apis/gdata_errorcode.h"
+
+class FilePath;
+
+namespace gdata {
+
+// Interface for classes that need to observe events from classes implementing
+// DriveFileSystemInterface.
+// All events are notified on UI thread.
+class DriveFileSystemObserver {
+ public:
+ // Triggered when a content of a directory has been changed.
+ // |directory_path| is a virtual directory path (/drive/...) representing
+ // changed directory.
+ virtual void OnDirectoryChanged(const FilePath& directory_path) {
+ }
+
+ // Triggered when the file system is initially loaded.
+ virtual void OnInitialLoadFinished(DriveFileError error) {
+ }
+
+ // Triggered when a document feed is fetched. |num_accumulated_entries|
+ // tells the number of entries fetched so far.
+ virtual void OnDocumentFeedFetched(int num_accumulated_entries) {
+ }
+
+ // Triggered when the feed from the server is loaded.
+ virtual void OnFeedFromServerLoaded() {
+ }
+
+ // Triggered when the file system is mounted.
+ virtual void OnFileSystemMounted() {
+ }
+
+ // Triggered when the file system is being unmounted.
+ virtual void OnFileSystemBeingUnmounted() {
+ }
+
+ protected:
+ virtual ~DriveFileSystemObserver() {}
+};
+
+} // namespace gdata
+
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_OBSERVER_H_
diff --git a/chrome/browser/chromeos/gdata/drive_sync_client.cc b/chrome/browser/chromeos/gdata/drive_sync_client.cc
index fe8cb29..e7b3a86 100644
--- a/chrome/browser/chromeos/gdata/drive_sync_client.cc
+++ b/chrome/browser/chromeos/gdata/drive_sync_client.cc
@@ -11,6 +11,7 @@
#include "base/message_loop_proxy.h"
#include "chrome/browser/api/prefs/pref_change_registrar.h"
#include "chrome/browser/chromeos/gdata/drive.pb.h"
+#include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
#include "chrome/browser/chromeos/gdata/drive_file_system_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chrome/browser/chromeos/gdata/drive_sync_client.h b/chrome/browser/chromeos/gdata/drive_sync_client.h
index 4e8ebb5..5cdbf26 100644
--- a/chrome/browser/chromeos/gdata/drive_sync_client.h
+++ b/chrome/browser/chromeos/gdata/drive_sync_client.h
@@ -13,7 +13,9 @@
#include "base/memory/weak_ptr.h"
#include "base/time.h"
#include "chrome/browser/chromeos/gdata/drive_cache.h"
-#include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
+#include "chrome/browser/chromeos/gdata/drive_cache_observer.h"
+#include "chrome/browser/chromeos/gdata/drive_file_system_observer.h"
+#include "chrome/browser/chromeos/gdata/drive_resource_metadata.h"
#include "content/public/browser/notification_observer.h"
#include "net/base/network_change_notifier.h"
@@ -22,6 +24,9 @@ class PrefChangeRegistrar;
namespace gdata {
+class DriveEntryProto;
+class DriveFileSystemInterface;
+
// The DriveSyncClient is used to synchronize pinned files on Drive and the
// cache on the local drive. The sync client works as follows.
//
@@ -40,8 +45,8 @@ namespace gdata {
// edited) files to Drive. Will work on this once downloading is done.
// crosbug.com/27836.
class DriveSyncClient
- : public DriveFileSystemInterface::Observer,
- public DriveCache::Observer,
+ : public DriveFileSystemObserver,
+ public DriveCacheObserver,
public content::NotificationObserver,
public net::NetworkChangeNotifier::ConnectionTypeObserver{
public:
diff --git a/chrome/browser/chromeos/gdata/drive_task_executor.cc b/chrome/browser/chromeos/gdata/drive_task_executor.cc
index 67e54bb..7699dcf 100644
--- a/chrome/browser/chromeos/gdata/drive_task_executor.cc
+++ b/chrome/browser/chromeos/gdata/drive_task_executor.cc
@@ -11,6 +11,7 @@
#include "base/string_util.h"
#include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
#include "chrome/browser/chromeos/gdata/drive.pb.h"
+#include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
#include "chrome/browser/chromeos/gdata/drive_service_interface.h"
#include "chrome/browser/chromeos/gdata/drive_system_service.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc b/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc
index ef6e935..6d64042 100644
--- a/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc
+++ b/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/gdata/drive_file_system_util.h"
#include "chrome/browser/chromeos/gdata/drive_service_interface.h"
#include "chrome/browser/chromeos/gdata/drive_webapps_registry.h"
+#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader_observer.h"
#include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h"
#include "chrome/browser/google_apis/drive_api_parser.h"
#include "chrome/browser/google_apis/gdata_util.h"
@@ -229,12 +230,13 @@ GDataWapiFeedLoader::GDataWapiFeedLoader(
GDataWapiFeedLoader::~GDataWapiFeedLoader() {
}
-void GDataWapiFeedLoader::AddObserver(Observer* observer) {
+void GDataWapiFeedLoader::AddObserver(GDataWapiFeedLoaderObserver* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observers_.AddObserver(observer);
}
-void GDataWapiFeedLoader::RemoveObserver(Observer* observer) {
+void GDataWapiFeedLoader::RemoveObserver(
+ GDataWapiFeedLoaderObserver* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
observers_.RemoveObserver(observer);
}
@@ -508,7 +510,9 @@ void GDataWapiFeedLoader::OnFeedFromServerLoaded(
if (!params->load_finished_callback.is_null())
params->load_finished_callback.Run(DRIVE_FILE_OK);
- FOR_EACH_OBSERVER(Observer, observers_, OnFeedFromServerLoaded());
+ FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver,
+ observers_,
+ OnFeedFromServerLoaded());
}
void GDataWapiFeedLoader::OnGetDocuments(
@@ -611,7 +615,7 @@ void GDataWapiFeedLoader::OnParseFeed(scoped_ptr<LoadFeedParams> params,
}
// Notify the observers that all document feeds are fetched.
- FOR_EACH_OBSERVER(Observer, observers_,
+ FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver, observers_,
OnDocumentFeedFetched(num_accumulated_entries));
UMA_HISTOGRAM_TIMES("Drive.EntireFeedLoadTime",
@@ -715,7 +719,7 @@ void GDataWapiFeedLoader::OnGetChangelist(
}
// Notify the observers that all document feeds are fetched.
- FOR_EACH_OBSERVER(Observer, observers_,
+ FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver, observers_,
OnDocumentFeedFetched(num_accumulated_entries));
UMA_HISTOGRAM_TIMES("Drive.EntireFeedLoadTime",
@@ -741,7 +745,7 @@ void GDataWapiFeedLoader::OnNotifyDocumentFeedFetched(
if (ui_state->num_showing_documents + kFetchUiUpdateStep <=
ui_state->num_fetched_documents) {
ui_state->num_showing_documents += kFetchUiUpdateStep;
- FOR_EACH_OBSERVER(Observer, observers_,
+ FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver, observers_,
OnDocumentFeedFetched(ui_state->num_showing_documents));
int num_remaining_ui_updates =
@@ -902,7 +906,7 @@ DriveFileError GDataWapiFeedLoader::UpdateFromFeed(
if (should_notify_directory_changed) {
for (std::set<FilePath>::iterator dir_iter = changed_dirs.begin();
dir_iter != changed_dirs.end(); ++dir_iter) {
- FOR_EACH_OBSERVER(Observer, observers_,
+ FOR_EACH_OBSERVER(GDataWapiFeedLoaderObserver, observers_,
OnDirectoryChanged(*dir_iter));
}
}
diff --git a/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h b/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h
index 2e6c22e..5a3a651 100644
--- a/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h
+++ b/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h
@@ -27,6 +27,7 @@ class DocumentFeed;
class DriveCache;
class DriveServiceInterface;
class DriveWebAppsRegistryInterface;
+class GDataWapiFeedLoaderObserver;
struct GetDocumentsUiState;
struct LoadFeedParams;
@@ -91,26 +92,6 @@ struct LoadRootFeedParams {
// Documents List API) and load the cached proto file.
class GDataWapiFeedLoader {
public:
- // Used to notify events from the loader.
- // All events are notified on UI thread.
- class Observer {
- public:
- // Triggered when a content of a directory has been changed.
- // |directory_path| is a virtual directory path representing the
- // changed directory.
- virtual void OnDirectoryChanged(const FilePath& directory_path) {}
-
- // Triggered when a document feed is fetched. |num_accumulated_entries|
- // tells the number of entries fetched so far.
- virtual void OnDocumentFeedFetched(int num_accumulated_entries) {}
-
- // Triggered when the feed from the server is loaded.
- virtual void OnFeedFromServerLoaded() {}
-
- protected:
- virtual ~Observer() {}
- };
-
GDataWapiFeedLoader(
DriveResourceMetadata* resource_metadata,
DriveServiceInterface* drive_service,
@@ -120,8 +101,8 @@ class GDataWapiFeedLoader {
~GDataWapiFeedLoader();
// Adds and removes the observer.
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
+ void AddObserver(GDataWapiFeedLoaderObserver* observer);
+ void RemoveObserver(GDataWapiFeedLoaderObserver* observer);
// Starts root feed load from the cache. If successful, runs |callback| to
// tell the caller that the loading was successful.
@@ -253,7 +234,7 @@ class GDataWapiFeedLoader {
DriveWebAppsRegistryInterface* webapps_registry_; // Not owned.
DriveCache* cache_; // Not owned.
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
- ObserverList<Observer> observers_;
+ ObserverList<GDataWapiFeedLoaderObserver> observers_;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
diff --git a/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader_observer.h b/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader_observer.h
new file mode 100644
index 0000000..a242e81
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/gdata_wapi_feed_loader_observer.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_OBSERVER_H_
+
+#include <string>
+
+class FilePath;
+
+namespace gdata {
+
+// Interface for classes that need to observe events from GdataWapiFeedLoader.
+// All events are notified on UI thread.
+class GDataWapiFeedLoaderObserver {
+ public:
+ // Triggered when a content of a directory has been changed.
+ // |directory_path| is a virtual directory path representing the
+ // changed directory.
+ virtual void OnDirectoryChanged(const FilePath& directory_path) {
+ }
+
+ // Triggered when a document feed is fetched. |num_accumulated_entries|
+ // tells the number of entries fetched so far.
+ virtual void OnDocumentFeedFetched(int num_accumulated_entries) {
+ }
+
+ // Triggered when the feed from the server is loaded.
+ virtual void OnFeedFromServerLoaded() {
+ }
+
+ protected:
+ virtual ~GDataWapiFeedLoaderObserver() {}
+};
+
+} // namespace gdata
+
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_OBSERVER_H_
diff --git a/chrome/browser/chromeos/gdata/gdata_wapi_service.cc b/chrome/browser/chromeos/gdata/gdata_wapi_service.cc
index 5d2165d..5b5eb9a 100644
--- a/chrome/browser/chromeos/gdata/gdata_wapi_service.cc
+++ b/chrome/browser/chromeos/gdata/gdata_wapi_service.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/message_loop_proxy.h"
+#include "chrome/browser/google_apis/auth_service.h"
#include "chrome/browser/google_apis/drive_api_operations.h"
#include "chrome/browser/google_apis/gdata_operations.h"
#include "chrome/browser/google_apis/gdata_util.h"
diff --git a/chrome/browser/chromeos/gdata/gdata_wapi_service.h b/chrome/browser/chromeos/gdata/gdata_wapi_service.h
index 53d7084..60d53b1 100644
--- a/chrome/browser/chromeos/gdata/gdata_wapi_service.h
+++ b/chrome/browser/chromeos/gdata/gdata_wapi_service.h
@@ -11,7 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/gdata/drive_service_interface.h"
-#include "chrome/browser/google_apis/auth_service.h"
+#include "chrome/browser/google_apis/auth_service_observer.h"
#include "chrome/browser/google_apis/gdata_operations.h"
class FilePath;
@@ -20,6 +20,7 @@ class Profile;
namespace gdata {
+class AuthService;
class OperationRunner;
// This class provides documents feed service calls for WAPI (codename for
@@ -27,8 +28,8 @@ class OperationRunner;
// Details of API call are abstracted in each operation class and this class
// works as a thin wrapper for the API.
class GDataWapiService : public DriveServiceInterface,
- public AuthService::Observer,
- public OperationRegistry::Observer {
+ public AuthServiceObserver,
+ public OperationRegistryObserver {
public:
// Instance is usually created by DriveSystemServiceFactory and owned by
// DriveFileSystem.
diff --git a/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc b/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc
index 5aac75c..3b6b0d9 100644
--- a/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_wapi_service_browsertest.cc
@@ -8,6 +8,7 @@
#include "base/file_util.h"
#include "base/json/json_reader.h"
#include "chrome/browser/chromeos/gdata/gdata_wapi_service.h"
+#include "chrome/browser/google_apis/auth_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
diff --git a/chrome/browser/chromeos/gdata/mock_directory_change_observer.h b/chrome/browser/chromeos/gdata/mock_directory_change_observer.h
index 56dc1bf..b3a01e0 100644
--- a/chrome/browser/chromeos/gdata/mock_directory_change_observer.h
+++ b/chrome/browser/chromeos/gdata/mock_directory_change_observer.h
@@ -5,13 +5,14 @@
#ifndef CHROME_BROWSER_CHROMEOS_GDATA_MOCK_DIRECTORY_CHANGE_OBSERVER_H_
#define CHROME_BROWSER_CHROMEOS_GDATA_MOCK_DIRECTORY_CHANGE_OBSERVER_H_
-#include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
+#include "base/file_path.h"
+#include "chrome/browser/chromeos/gdata/drive_file_system_observer.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace gdata {
// Mock for DriveFileSystemInterface::Observer::OnDirectoryChanged().
-class MockDirectoryChangeObserver : public DriveFileSystemInterface::Observer {
+class MockDirectoryChangeObserver : public DriveFileSystemObserver {
public:
MockDirectoryChangeObserver();
virtual ~MockDirectoryChangeObserver();
diff --git a/chrome/browser/chromeos/gdata/mock_drive_cache_observer.h b/chrome/browser/chromeos/gdata/mock_drive_cache_observer.h
index c43758e..c02ea90 100644
--- a/chrome/browser/chromeos/gdata/mock_drive_cache_observer.h
+++ b/chrome/browser/chromeos/gdata/mock_drive_cache_observer.h
@@ -7,13 +7,13 @@
#include <string>
-#include "chrome/browser/chromeos/gdata/drive_cache.h"
+#include "chrome/browser/chromeos/gdata/drive_cache_observer.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace gdata {
// Mock for DriveCache::Observer.
-class MockDriveCacheObserver : public DriveCache::Observer {
+class MockDriveCacheObserver : public DriveCacheObserver {
public:
MockDriveCacheObserver();
virtual ~MockDriveCacheObserver();
diff --git a/chrome/browser/chromeos/gdata/mock_drive_file_system.h b/chrome/browser/chromeos/gdata/mock_drive_file_system.h
index e545cfc..8a34c74 100644
--- a/chrome/browser/chromeos/gdata/mock_drive_file_system.h
+++ b/chrome/browser/chromeos/gdata/mock_drive_file_system.h
@@ -12,6 +12,8 @@
namespace gdata {
+class DriveFileSystemObserver;
+
// Mock for DriveFileSystemInterface.
class MockDriveFileSystem : public DriveFileSystemInterface {
public:
@@ -20,8 +22,9 @@ class MockDriveFileSystem : public DriveFileSystemInterface {
// DriveFileSystemInterface overrides.
MOCK_METHOD0(Initialize, void());
- MOCK_METHOD1(AddObserver, void(Observer* observer));
- MOCK_METHOD1(RemoveObserver, void(Observer* observer));
+ MOCK_METHOD1(AddObserver, void(DriveFileSystemObserver* observer));
+ MOCK_METHOD1(RemoveObserver,
+ void(DriveFileSystemObserver* observer));
MOCK_METHOD0(StartInitialFeedFetch, void());
MOCK_METHOD0(StartUpdates, void());
MOCK_METHOD0(StopUpdates, void());
diff --git a/chrome/browser/chromeos/gdata/stale_cache_files_remover.h b/chrome/browser/chromeos/gdata/stale_cache_files_remover.h
index 8940384..23c69da 100644
--- a/chrome/browser/chromeos/gdata/stale_cache_files_remover.h
+++ b/chrome/browser/chromeos/gdata/stale_cache_files_remover.h
@@ -8,18 +8,22 @@
#include <string>
#include <vector>
-#include "base/basictypes.h"
-#include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/gdata/drive.pb.h"
+#include "chrome/browser/chromeos/gdata/drive_file_system_observer.h"
+#include "chrome/browser/google_apis/gdata_errorcode.h"
namespace gdata{
class DriveCache;
-class DriveFileSystem;
+class DriveCacheEntry;
+class DriveFileSystemInterface;
// This class removes stale cache files, which are present locally, but no
// longer present on the server. This can happen if files are removed from the
// server from other devices, or from the web interface.
-class StaleCacheFilesRemover : public DriveFileSystemInterface::Observer {
+class StaleCacheFilesRemover : public DriveFileSystemObserver {
public:
StaleCacheFilesRemover(DriveFileSystemInterface* file_system,
DriveCache* cache);