Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/chromeos/drive/drive_system_service.h

Issue 13866050: drive: Introduce DriveSystemServiceObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
14 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
15 #include "chrome/browser/chromeos/drive/drive_file_error.h" 16 #include "chrome/browser/chromeos/drive/drive_file_error.h"
16 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" 17 #include "chrome/browser/chromeos/drive/drive_file_system_util.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h" 18 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "chrome/browser/profiles/profile_keyed_service_factory.h" 19 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
19 #include "sync/notifier/invalidation_handler.h" 20 #include "sync/notifier/invalidation_handler.h"
20 21
21 namespace base { 22 namespace base {
22 class FilePath; 23 class FilePath;
23 } 24 }
24 25
25 namespace google_apis { 26 namespace google_apis {
26 class DriveServiceInterface; 27 class DriveServiceInterface;
27 } 28 }
28 29
29 namespace drive { 30 namespace drive {
30 31
31 class DriveCache; 32 class DriveCache;
32 class DriveDownloadHandler; 33 class DriveDownloadHandler;
33 class DriveFileSystemInterface; 34 class DriveFileSystemInterface;
34 class DriveFileSystemProxy; 35 class DriveFileSystemProxy;
35 class DriveWebAppsRegistry; 36 class DriveWebAppsRegistry;
36 class DriveSyncClient; 37 class DriveSyncClient;
37 class DrivePrefetcher; 38 class DrivePrefetcher;
38 class DriveResourceMetadata; 39 class DriveResourceMetadata;
39 class EventLogger; 40 class EventLogger;
40 class FileWriteHelper; 41 class FileWriteHelper;
41 class StaleCacheFilesRemover; 42 class StaleCacheFilesRemover;
42 43
44 // Interface for classes that need to observe events from DriveSystemService.
45 // All events are notified on UI thread.
46 class DriveSystemServiceObserver {
47 public:
48 // Triggered when the file system is mounted.
49 virtual void OnFileSystemMounted() {
50 }
51
52 // Triggered when the file system is being unmounted.
53 virtual void OnFileSystemBeingUnmounted() {
54 }
55
56 protected:
57 virtual ~DriveSystemServiceObserver() {}
58 };
59
43 // DriveSystemService runs the Drive system, including the Drive file system 60 // DriveSystemService runs the Drive system, including the Drive file system
44 // implementation for the file manager, and some other sub systems. 61 // implementation for the file manager, and some other sub systems.
45 // 62 //
46 // The class is essentially a container that manages lifetime of the objects 63 // The class is essentially a container that manages lifetime of the objects
47 // that are used to run the Drive system. The DriveSystemService object is 64 // that are used to run the Drive system. The DriveSystemService object is
48 // created per-profile. 65 // created per-profile.
49 class DriveSystemService : public ProfileKeyedService, 66 class DriveSystemService : public ProfileKeyedService,
50 public syncer::InvalidationHandler { 67 public syncer::InvalidationHandler {
51 public: 68 public:
52 // test_drive_service, test_cache_root and test_file_system are used by tests 69 // test_drive_service, test_cache_root and test_file_system are used by tests
53 // to inject customized instances. 70 // to inject customized instances.
54 // Pass NULL or the empty value when not interested. 71 // Pass NULL or the empty value when not interested.
55 DriveSystemService(Profile* profile, 72 DriveSystemService(Profile* profile,
56 google_apis::DriveServiceInterface* test_drive_service, 73 google_apis::DriveServiceInterface* test_drive_service,
57 const base::FilePath& test_cache_root, 74 const base::FilePath& test_cache_root,
58 DriveFileSystemInterface* test_file_system); 75 DriveFileSystemInterface* test_file_system);
59 virtual ~DriveSystemService(); 76 virtual ~DriveSystemService();
60 77
61 // Initializes the object. This function should be called before any 78 // Initializes the object. This function should be called before any
62 // other functions. 79 // other functions.
63 void Initialize(); 80 void Initialize();
64 81
65 // ProfileKeyedService override: 82 // ProfileKeyedService override:
66 virtual void Shutdown() OVERRIDE; 83 virtual void Shutdown() OVERRIDE;
67 84
85 // Adds and removes the observer.
86 void AddObserver(DriveSystemServiceObserver* observer);
87 void RemoveObserver(DriveSystemServiceObserver* observer);
88
68 google_apis::DriveServiceInterface* drive_service() { 89 google_apis::DriveServiceInterface* drive_service() {
69 return drive_service_.get(); 90 return drive_service_.get();
70 } 91 }
71 92
72 DriveCache* cache() { return cache_.get(); } 93 DriveCache* cache() { return cache_.get(); }
73 DriveFileSystemInterface* file_system() { return file_system_.get(); } 94 DriveFileSystemInterface* file_system() { return file_system_.get(); }
74 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); } 95 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); }
75 DriveDownloadHandler* download_handler() { return download_handler_.get(); } 96 DriveDownloadHandler* download_handler() { return download_handler_.get(); }
76 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } 97 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); }
77 EventLogger* event_logger() { return event_logger_.get(); } 98 EventLogger* event_logger() { return event_logger_.get(); }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; 166 scoped_ptr<DriveWebAppsRegistry> webapps_registry_;
146 scoped_ptr<DriveResourceMetadata, util::DestroyHelper> resource_metadata_; 167 scoped_ptr<DriveResourceMetadata, util::DestroyHelper> resource_metadata_;
147 scoped_ptr<DriveFileSystemInterface> file_system_; 168 scoped_ptr<DriveFileSystemInterface> file_system_;
148 scoped_ptr<FileWriteHelper> file_write_helper_; 169 scoped_ptr<FileWriteHelper> file_write_helper_;
149 scoped_ptr<DriveDownloadHandler> download_handler_; 170 scoped_ptr<DriveDownloadHandler> download_handler_;
150 scoped_ptr<DriveSyncClient> sync_client_; 171 scoped_ptr<DriveSyncClient> sync_client_;
151 scoped_ptr<DrivePrefetcher> prefetcher_; 172 scoped_ptr<DrivePrefetcher> prefetcher_;
152 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_; 173 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_;
153 scoped_refptr<DriveFileSystemProxy> file_system_proxy_; 174 scoped_refptr<DriveFileSystemProxy> file_system_proxy_;
154 175
176 ObserverList<DriveSystemServiceObserver> observers_;
177
155 // Note: This should remain the last member so it'll be destroyed and 178 // Note: This should remain the last member so it'll be destroyed and
156 // invalidate its weak pointers before any other members are destroyed. 179 // invalidate its weak pointers before any other members are destroyed.
157 base::WeakPtrFactory<DriveSystemService> weak_ptr_factory_; 180 base::WeakPtrFactory<DriveSystemService> weak_ptr_factory_;
158 DISALLOW_COPY_AND_ASSIGN(DriveSystemService); 181 DISALLOW_COPY_AND_ASSIGN(DriveSystemService);
159 }; 182 };
160 183
161 // Singleton that owns all DriveSystemServices and associates them with 184 // Singleton that owns all DriveSystemServices and associates them with
162 // Profiles. 185 // Profiles.
163 class DriveSystemServiceFactory : public ProfileKeyedServiceFactory { 186 class DriveSystemServiceFactory : public ProfileKeyedServiceFactory {
164 public: 187 public:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // ProfileKeyedServiceFactory: 227 // ProfileKeyedServiceFactory:
205 virtual ProfileKeyedService* BuildServiceInstanceFor( 228 virtual ProfileKeyedService* BuildServiceInstanceFor(
206 Profile* profile) const OVERRIDE; 229 Profile* profile) const OVERRIDE;
207 230
208 FactoryCallback factory_for_test_; 231 FactoryCallback factory_for_test_;
209 }; 232 };
210 233
211 } // namespace drive 234 } // namespace drive
212 235
213 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_ 236 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system_observer.h ('k') | chrome/browser/chromeos/drive/drive_system_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698