| Index: chrome/browser/chromeos/extensions/file_browser_event_router.h
|
| ===================================================================
|
| --- chrome/browser/chromeos/extensions/file_browser_event_router.h (revision 127341)
|
| +++ chrome/browser/chromeos/extensions/file_browser_event_router.h (working copy)
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// 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.
|
|
|
| @@ -16,17 +16,24 @@
|
| #include "base/string16.h"
|
| #include "base/synchronization/lock.h"
|
| #include "chrome/browser/chromeos/disks/disk_mount_manager.h"
|
| +#include "chrome/browser/chromeos/gdata/gdata_file_system.h"
|
| +#include "chrome/browser/chromeos/gdata/gdata_operation_registry.h"
|
| +#include "chrome/browser/profiles/profile_keyed_service.h"
|
| +#include "chrome/browser/profiles/profile_keyed_service_factory.h"
|
|
|
| class FileBrowserNotifications;
|
| class Profile;
|
|
|
| // Used to monitor disk mount changes and signal when new mounted usb device is
|
| // found.
|
| -class ExtensionFileBrowserEventRouter
|
| - : public chromeos::disks::DiskMountManager::Observer {
|
| +class FileBrowserEventRouter
|
| + : public ProfileKeyedService,
|
| + public chromeos::disks::DiskMountManager::Observer,
|
| + public gdata::GDataOperationRegistry::Observer {
|
| public:
|
| - explicit ExtensionFileBrowserEventRouter(Profile* profile);
|
| - virtual ~ExtensionFileBrowserEventRouter();
|
| + // ProfileKeyedService overrides.
|
| + virtual void Shutdown() OVERRIDE;
|
| +
|
| // Starts observing file system change events. Currently only
|
| // CrosDisksClient events are being observed.
|
| void ObserveFileSystemEvents();
|
| @@ -50,11 +57,18 @@
|
| const chromeos::disks::DiskMountManager::MountPointInfo& mount_info)
|
| OVERRIDE;
|
|
|
| + // GDataOperationRegistry::Observer overrides.
|
| + virtual void OnProgressUpdate(
|
| + const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list)
|
| + OVERRIDE;
|
| +
|
| private:
|
| + friend class FileBrowserEventRouterFactory;
|
| +
|
| // Helper class for passing through file watch notification events.
|
| class FileWatcherDelegate : public base::files::FilePathWatcher::Delegate {
|
| public:
|
| - explicit FileWatcherDelegate(ExtensionFileBrowserEventRouter* router);
|
| + explicit FileWatcherDelegate(FileBrowserEventRouter* router);
|
|
|
| private:
|
| // base::files::FilePathWatcher::Delegate overrides.
|
| @@ -63,7 +77,7 @@
|
|
|
| void HandleFileWatchOnUIThread(const FilePath& local_path, bool got_error);
|
|
|
| - ExtensionFileBrowserEventRouter* router_;
|
| + FileBrowserEventRouter* router_;
|
| };
|
|
|
| typedef std::map<std::string, int> ExtensionUsageRegistry;
|
| @@ -97,6 +111,9 @@
|
|
|
| typedef std::map<FilePath, FileWatcherExtensions*> WatcherMap;
|
|
|
| + explicit FileBrowserEventRouter(Profile* profile);
|
| + virtual ~FileBrowserEventRouter();
|
| +
|
| // USB mount event handlers.
|
| void OnDiskAdded(const chromeos::disks::DiskMountManager::Disk* disk);
|
| void OnDiskRemoved(const chromeos::disks::DiskMountManager::Disk* disk);
|
| @@ -139,7 +156,30 @@
|
| Profile* profile_;
|
| base::Lock lock_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter);
|
| + DISALLOW_COPY_AND_ASSIGN(FileBrowserEventRouter);
|
| };
|
|
|
| +// Singleton that owns all FileBrowserEventRouter and associates
|
| +// them with Profiles.
|
| +class FileBrowserEventRouterFactory
|
| + : public ProfileKeyedServiceFactory {
|
| + public:
|
| + // Returns the FileBrowserEventRouter for |profile|, creating it if
|
| + // it is not yet created.
|
| + static FileBrowserEventRouter* GetForProfile(Profile* profile);
|
| +
|
| + // Returns the FileBrowserEventRouterFactory instance.
|
| + static FileBrowserEventRouterFactory* GetInstance();
|
| +
|
| + private:
|
| + friend struct DefaultSingletonTraits<FileBrowserEventRouterFactory>;
|
| +
|
| + FileBrowserEventRouterFactory();
|
| + virtual ~FileBrowserEventRouterFactory();
|
| +
|
| + // ProfileKeyedServiceFactory:
|
| + virtual ProfileKeyedService* BuildServiceInstanceFor(
|
| + Profile* profile) const OVERRIDE;
|
| +};
|
| +
|
| #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_
|
|
|