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

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

Issue 13891016: Merge ChromeOS and SyncFS XMPP Notification into one class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unused includes 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_system_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/observer_list.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
16 #include "chrome/browser/chromeos/drive/drive_file_error.h" 16 #include "chrome/browser/chromeos/drive/drive_file_error.h"
17 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" 17 #include "chrome/browser/chromeos/drive/drive_file_system_util.h"
18 #include "chrome/browser/chromeos/drive/drive_scheduler.h" 18 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
19 #include "chrome/browser/google_apis/drive_notification_observer.h"
19 #include "chrome/browser/profiles/profile_keyed_service.h" 20 #include "chrome/browser/profiles/profile_keyed_service.h"
20 #include "chrome/browser/profiles/profile_keyed_service_factory.h" 21 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
21 #include "sync/notifier/invalidation_handler.h"
22 22
23 namespace base { 23 namespace base {
24 class FilePath; 24 class FilePath;
25 } 25 }
26 26
27 namespace google_apis { 27 namespace google_apis {
28 class DriveServiceInterface; 28 class DriveServiceInterface;
29 } 29 }
30 30
31 namespace drive { 31 namespace drive {
(...skipping 26 matching lines...) Expand all
58 protected: 58 protected:
59 virtual ~DriveSystemServiceObserver() {} 59 virtual ~DriveSystemServiceObserver() {}
60 }; 60 };
61 61
62 // DriveSystemService runs the Drive system, including the Drive file system 62 // DriveSystemService runs the Drive system, including the Drive file system
63 // implementation for the file manager, and some other sub systems. 63 // implementation for the file manager, and some other sub systems.
64 // 64 //
65 // The class is essentially a container that manages lifetime of the objects 65 // The class is essentially a container that manages lifetime of the objects
66 // that are used to run the Drive system. The DriveSystemService object is 66 // that are used to run the Drive system. The DriveSystemService object is
67 // created per-profile. 67 // created per-profile.
68 class DriveSystemService : public ProfileKeyedService, 68 class DriveSystemService
69 public syncer::InvalidationHandler { 69 : public ProfileKeyedService,
70 public google_apis::DriveNotificationObserver {
70 public: 71 public:
71 // test_drive_service, test_cache_root and test_file_system are used by tests 72 // test_drive_service, test_cache_root and test_file_system are used by tests
72 // to inject customized instances. 73 // to inject customized instances.
73 // Pass NULL or the empty value when not interested. 74 // Pass NULL or the empty value when not interested.
74 DriveSystemService(Profile* profile, 75 DriveSystemService(Profile* profile,
75 google_apis::DriveServiceInterface* test_drive_service, 76 google_apis::DriveServiceInterface* test_drive_service,
76 const base::FilePath& test_cache_root, 77 const base::FilePath& test_cache_root,
77 DriveFileSystemInterface* test_file_system); 78 DriveFileSystemInterface* test_file_system);
78 virtual ~DriveSystemService(); 79 virtual ~DriveSystemService();
79 80
80 // Initializes the object. This function should be called before any 81 // Initializes the object. This function should be called before any
81 // other functions. 82 // other functions.
82 void Initialize(); 83 void Initialize();
83 84
84 // ProfileKeyedService override: 85 // ProfileKeyedService override:
85 virtual void Shutdown() OVERRIDE; 86 virtual void Shutdown() OVERRIDE;
86 87
87 // Adds and removes the observer. 88 // Adds and removes the observer.
88 void AddObserver(DriveSystemServiceObserver* observer); 89 void AddObserver(DriveSystemServiceObserver* observer);
89 void RemoveObserver(DriveSystemServiceObserver* observer); 90 void RemoveObserver(DriveSystemServiceObserver* observer);
90 91
92 // google_apis::DriveNotificationObserver implementation.
93 virtual void CheckForUpdates() OVERRIDE;
satorux1 2013/04/19 07:28:25 I found it rather unusual for a function name of a
calvinlo 2013/04/19 07:54:06 Done. Originally I called it CheckForUpdates becau
94
91 google_apis::DriveServiceInterface* drive_service() { 95 google_apis::DriveServiceInterface* drive_service() {
92 return drive_service_.get(); 96 return drive_service_.get();
93 } 97 }
94 98
95 DriveCache* cache() { return cache_.get(); } 99 DriveCache* cache() { return cache_.get(); }
96 DriveFileSystemInterface* file_system() { return file_system_.get(); } 100 DriveFileSystemInterface* file_system() { return file_system_.get(); }
97 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); } 101 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); }
98 DriveDownloadHandler* download_handler() { return download_handler_.get(); } 102 DriveDownloadHandler* download_handler() { return download_handler_.get(); }
99 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } 103 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); }
100 EventLogger* event_logger() { return event_logger_.get(); } 104 EventLogger* event_logger() { return event_logger_.get(); }
101 JobListInterface* job_list() { return scheduler_.get(); } 105 JobListInterface* job_list() { return scheduler_.get(); }
102 106
103 // Clears all the local cache files and in-memory data, and remounts the 107 // Clears all the local cache files and in-memory data, and remounts the
104 // file system. |callback| is called with true when this operation is done 108 // file system. |callback| is called with true when this operation is done
105 // successfully. Otherwise, |callback| is called with false. 109 // successfully. Otherwise, |callback| is called with false.
106 // |callback| must not be null. 110 // |callback| must not be null.
107 void ClearCacheAndRemountFileSystem( 111 void ClearCacheAndRemountFileSystem(
108 const base::Callback<void(bool)>& callback); 112 const base::Callback<void(bool)>& callback);
109 113
110 // Reloads and remounts the file system. 114 // Reloads and remounts the file system.
111 void ReloadAndRemountFileSystem(); 115 void ReloadAndRemountFileSystem();
112 116
113 // Returns true if the push notification is enabled.
114 bool PushNotificationEnabled();
115
116 private: 117 private:
117 // syncer::InvalidationHandler implementation.
118 virtual void OnInvalidatorStateChange(
119 syncer::InvalidatorState state) OVERRIDE;
120 virtual void OnIncomingInvalidation(
121 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
122
123 // Returns true if Drive is enabled. 118 // Returns true if Drive is enabled.
124 // Must be called on UI thread. 119 // Must be called on UI thread.
125 bool IsDriveEnabled(); 120 bool IsDriveEnabled();
126 121
127 // Registers remote file system proxy for drive mount point. 122 // Registers remote file system proxy for drive mount point.
128 void AddDriveMountPoint(); 123 void AddDriveMountPoint();
129 // Unregisters drive mount point from File API. 124 // Unregisters drive mount point from File API.
130 void RemoveDriveMountPoint(); 125 void RemoveDriveMountPoint();
131 126
132 // Reinitializes |resource_metadata_|. 127 // Reinitializes |resource_metadata_|.
(...skipping 19 matching lines...) Expand all
152 // the Drive cache failed). 147 // the Drive cache failed).
153 // Must be called on UI thread. 148 // Must be called on UI thread.
154 void DisableDrive(); 149 void DisableDrive();
155 150
156 friend class DriveSystemServiceFactory; 151 friend class DriveSystemServiceFactory;
157 152
158 Profile* profile_; 153 Profile* profile_;
159 // True if Drive is disabled due to initialization errors. 154 // True if Drive is disabled due to initialization errors.
160 bool drive_disabled_; 155 bool drive_disabled_;
161 156
162 // True once this is registered to listen to the Drive updates.
163 bool push_notification_registered_;
164
165 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 157 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
166 scoped_ptr<EventLogger> event_logger_; 158 scoped_ptr<EventLogger> event_logger_;
167 scoped_ptr<DriveCache, util::DestroyHelper> cache_; 159 scoped_ptr<DriveCache, util::DestroyHelper> cache_;
168 scoped_ptr<google_apis::DriveServiceInterface> drive_service_; 160 scoped_ptr<google_apis::DriveServiceInterface> drive_service_;
169 scoped_ptr<DriveScheduler> scheduler_; 161 scoped_ptr<DriveScheduler> scheduler_;
170 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; 162 scoped_ptr<DriveWebAppsRegistry> webapps_registry_;
171 scoped_ptr<DriveResourceMetadata, util::DestroyHelper> resource_metadata_; 163 scoped_ptr<DriveResourceMetadata, util::DestroyHelper> resource_metadata_;
172 scoped_ptr<DriveFileSystemInterface> file_system_; 164 scoped_ptr<DriveFileSystemInterface> file_system_;
173 scoped_ptr<FileWriteHelper> file_write_helper_; 165 scoped_ptr<FileWriteHelper> file_write_helper_;
174 scoped_ptr<DriveDownloadHandler> download_handler_; 166 scoped_ptr<DriveDownloadHandler> download_handler_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // ProfileKeyedServiceFactory: 223 // ProfileKeyedServiceFactory:
232 virtual ProfileKeyedService* BuildServiceInstanceFor( 224 virtual ProfileKeyedService* BuildServiceInstanceFor(
233 Profile* profile) const OVERRIDE; 225 Profile* profile) const OVERRIDE;
234 226
235 FactoryCallback factory_for_test_; 227 FactoryCallback factory_for_test_;
236 }; 228 };
237 229
238 } // namespace drive 230 } // namespace drive
239 231
240 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_ 232 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_system_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698