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

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

Issue 13976019: Reland of https://codereview.chromium.org/13891016/. This includes the fix for the Segfault on Chro… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final rebase before dcommit attempt 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/file_errors.h" 16 #include "chrome/browser/chromeos/drive/file_errors.h"
17 #include "chrome/browser/chromeos/drive/file_system_util.h" 17 #include "chrome/browser/chromeos/drive/file_system_util.h"
18 #include "chrome/browser/chromeos/drive/job_scheduler.h" 18 #include "chrome/browser/chromeos/drive/job_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 25 matching lines...) Expand all
57 protected: 57 protected:
58 virtual ~DriveSystemServiceObserver() {} 58 virtual ~DriveSystemServiceObserver() {}
59 }; 59 };
60 60
61 // DriveSystemService runs the Drive system, including the Drive file system 61 // DriveSystemService runs the Drive system, including the Drive file system
62 // implementation for the file manager, and some other sub systems. 62 // implementation for the file manager, and some other sub systems.
63 // 63 //
64 // The class is essentially a container that manages lifetime of the objects 64 // The class is essentially a container that manages lifetime of the objects
65 // that are used to run the Drive system. The DriveSystemService object is 65 // that are used to run the Drive system. The DriveSystemService object is
66 // created per-profile. 66 // created per-profile.
67 class DriveSystemService : public ProfileKeyedService, 67 class DriveSystemService
68 public syncer::InvalidationHandler { 68 : public ProfileKeyedService,
69 public google_apis::DriveNotificationObserver {
69 public: 70 public:
70 // test_drive_service, test_cache_root and test_file_system are used by tests 71 // test_drive_service, test_cache_root and test_file_system are used by tests
71 // to inject customized instances. 72 // to inject customized instances.
72 // Pass NULL or the empty value when not interested. 73 // Pass NULL or the empty value when not interested.
73 DriveSystemService(Profile* profile, 74 DriveSystemService(Profile* profile,
74 google_apis::DriveServiceInterface* test_drive_service, 75 google_apis::DriveServiceInterface* test_drive_service,
75 const base::FilePath& test_cache_root, 76 const base::FilePath& test_cache_root,
76 DriveFileSystemInterface* test_file_system); 77 DriveFileSystemInterface* test_file_system);
77 virtual ~DriveSystemService(); 78 virtual ~DriveSystemService();
78 79
79 // Initializes the object. This function should be called before any 80 // Initializes the object. This function should be called before any
80 // other functions. 81 // other functions.
81 void Initialize(); 82 void Initialize();
82 83
83 // ProfileKeyedService override: 84 // ProfileKeyedService override:
84 virtual void Shutdown() OVERRIDE; 85 virtual void Shutdown() OVERRIDE;
85 86
86 // Adds and removes the observer. 87 // Adds and removes the observer.
87 void AddObserver(DriveSystemServiceObserver* observer); 88 void AddObserver(DriveSystemServiceObserver* observer);
88 void RemoveObserver(DriveSystemServiceObserver* observer); 89 void RemoveObserver(DriveSystemServiceObserver* observer);
89 90
91 // google_apis::DriveNotificationObserver implementation.
92 virtual void OnNotificationReceived() OVERRIDE;
93
90 google_apis::DriveServiceInterface* drive_service() { 94 google_apis::DriveServiceInterface* drive_service() {
91 return drive_service_.get(); 95 return drive_service_.get();
92 } 96 }
93 97
94 DriveCache* cache() { return cache_.get(); } 98 DriveCache* cache() { return cache_.get(); }
95 DriveFileSystemInterface* file_system() { return file_system_.get(); } 99 DriveFileSystemInterface* file_system() { return file_system_.get(); }
96 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); } 100 FileWriteHelper* file_write_helper() { return file_write_helper_.get(); }
97 DownloadHandler* download_handler() { return download_handler_.get(); } 101 DownloadHandler* download_handler() { return download_handler_.get(); }
98 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); } 102 DriveWebAppsRegistry* webapps_registry() { return webapps_registry_.get(); }
99 JobListInterface* job_list() { return scheduler_.get(); } 103 JobListInterface* job_list() { return scheduler_.get(); }
100 104
101 // Clears all the local cache files and in-memory data, and remounts the 105 // Clears all the local cache files and in-memory data, and remounts the
102 // file system. |callback| is called with true when this operation is done 106 // file system. |callback| is called with true when this operation is done
103 // successfully. Otherwise, |callback| is called with false. 107 // successfully. Otherwise, |callback| is called with false.
104 // |callback| must not be null. 108 // |callback| must not be null.
105 void ClearCacheAndRemountFileSystem( 109 void ClearCacheAndRemountFileSystem(
106 const base::Callback<void(bool)>& callback); 110 const base::Callback<void(bool)>& callback);
107 111
108 // Reloads and remounts the file system. 112 // Reloads and remounts the file system.
109 void ReloadAndRemountFileSystem(); 113 void ReloadAndRemountFileSystem();
110 114
111 // Returns true if the push notification is enabled.
112 bool PushNotificationEnabled();
113
114 private: 115 private:
115 // syncer::InvalidationHandler implementation.
116 virtual void OnInvalidatorStateChange(
117 syncer::InvalidatorState state) OVERRIDE;
118 virtual void OnIncomingInvalidation(
119 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
120
121 // Returns true if Drive is enabled. 116 // Returns true if Drive is enabled.
122 // Must be called on UI thread. 117 // Must be called on UI thread.
123 bool IsDriveEnabled(); 118 bool IsDriveEnabled();
124 119
125 // Registers remote file system proxy for drive mount point. 120 // Registers remote file system proxy for drive mount point.
126 void AddDriveMountPoint(); 121 void AddDriveMountPoint();
127 // Unregisters drive mount point from File API. 122 // Unregisters drive mount point from File API.
128 void RemoveDriveMountPoint(); 123 void RemoveDriveMountPoint();
129 124
130 // Reinitializes |resource_metadata_|. 125 // Reinitializes |resource_metadata_|.
(...skipping 19 matching lines...) Expand all
150 // the Drive cache failed). 145 // the Drive cache failed).
151 // Must be called on UI thread. 146 // Must be called on UI thread.
152 void DisableDrive(); 147 void DisableDrive();
153 148
154 friend class DriveSystemServiceFactory; 149 friend class DriveSystemServiceFactory;
155 150
156 Profile* profile_; 151 Profile* profile_;
157 // True if Drive is disabled due to initialization errors. 152 // True if Drive is disabled due to initialization errors.
158 bool drive_disabled_; 153 bool drive_disabled_;
159 154
160 // True once this is registered to listen to the Drive updates.
161 bool push_notification_registered_;
162
163 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 155 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
164 scoped_ptr<DriveCache, util::DestroyHelper> cache_; 156 scoped_ptr<DriveCache, util::DestroyHelper> cache_;
165 scoped_ptr<google_apis::DriveServiceInterface> drive_service_; 157 scoped_ptr<google_apis::DriveServiceInterface> drive_service_;
166 scoped_ptr<JobScheduler> scheduler_; 158 scoped_ptr<JobScheduler> scheduler_;
167 scoped_ptr<DriveWebAppsRegistry> webapps_registry_; 159 scoped_ptr<DriveWebAppsRegistry> webapps_registry_;
168 scoped_ptr<DriveResourceMetadata, util::DestroyHelper> resource_metadata_; 160 scoped_ptr<DriveResourceMetadata, util::DestroyHelper> resource_metadata_;
169 scoped_ptr<DriveFileSystemInterface> file_system_; 161 scoped_ptr<DriveFileSystemInterface> file_system_;
170 scoped_ptr<FileWriteHelper> file_write_helper_; 162 scoped_ptr<FileWriteHelper> file_write_helper_;
171 scoped_ptr<DownloadHandler> download_handler_; 163 scoped_ptr<DownloadHandler> download_handler_;
172 scoped_ptr<SyncClient> sync_client_; 164 scoped_ptr<SyncClient> sync_client_;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // ProfileKeyedServiceFactory: 220 // ProfileKeyedServiceFactory:
229 virtual ProfileKeyedService* BuildServiceInstanceFor( 221 virtual ProfileKeyedService* BuildServiceInstanceFor(
230 Profile* profile) const OVERRIDE; 222 Profile* profile) const OVERRIDE;
231 223
232 FactoryCallback factory_for_test_; 224 FactoryCallback factory_for_test_;
233 }; 225 };
234 226
235 } // namespace drive 227 } // namespace drive
236 228
237 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYSTEM_SERVICE_H_ 229 #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