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

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

Issue 11365249: drive: Event logger for chrome:drive-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 #include "chrome/browser/chromeos/drive/drive_system_service.h" 5 #include "chrome/browser/chromeos/drive/drive_system_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/drive/drive_api_service.h" 9 #include "chrome/browser/chromeos/drive/drive_api_service.h"
10 #include "chrome/browser/chromeos/drive/drive_download_observer.h" 10 #include "chrome/browser/chromeos/drive/drive_download_observer.h"
11 #include "chrome/browser/chromeos/drive/drive_file_system.h" 11 #include "chrome/browser/chromeos/drive/drive_file_system.h"
12 #include "chrome/browser/chromeos/drive/drive_file_system_proxy.h" 12 #include "chrome/browser/chromeos/drive/drive_file_system_proxy.h"
13 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" 13 #include "chrome/browser/chromeos/drive/drive_file_system_util.h"
14 #include "chrome/browser/chromeos/drive/drive_prefetcher.h" 14 #include "chrome/browser/chromeos/drive/drive_prefetcher.h"
15 #include "chrome/browser/chromeos/drive/drive_sync_client.h" 15 #include "chrome/browser/chromeos/drive/drive_sync_client.h"
16 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" 16 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h"
17 #include "chrome/browser/chromeos/drive/event_logger.h"
17 #include "chrome/browser/chromeos/drive/file_write_helper.h" 18 #include "chrome/browser/chromeos/drive/file_write_helper.h"
18 #include "chrome/browser/chromeos/drive/stale_cache_files_remover.h" 19 #include "chrome/browser/chromeos/drive/stale_cache_files_remover.h"
19 #include "chrome/browser/download/download_service.h" 20 #include "chrome/browser/download/download_service.h"
20 #include "chrome/browser/download/download_service_factory.h" 21 #include "chrome/browser/download/download_service_factory.h"
21 #include "chrome/browser/download/download_util.h" 22 #include "chrome/browser/download/download_util.h"
22 #include "chrome/browser/google_apis/drive_uploader.h" 23 #include "chrome/browser/google_apis/drive_uploader.h"
23 #include "chrome/browser/google_apis/gdata_util.h" 24 #include "chrome/browser/google_apis/gdata_util.h"
24 #include "chrome/browser/google_apis/gdata_wapi_service.h" 25 #include "chrome/browser/google_apis/gdata_wapi_service.h"
25 #include "chrome/browser/prefs/pref_service.h" 26 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/profiles/profile_dependency_manager.h" 28 #include "chrome/browser/profiles/profile_dependency_manager.h"
28 #include "chrome/browser/sync/profile_sync_service.h" 29 #include "chrome/browser/sync/profile_sync_service.h"
29 #include "chrome/browser/sync/profile_sync_service_factory.h" 30 #include "chrome/browser/sync/profile_sync_service_factory.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
31 #include "content/public/browser/browser_context.h" 32 #include "content/public/browser/browser_context.h"
32 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/storage_partition.h" 34 #include "content/public/browser/storage_partition.h"
34 #include "google/cacheinvalidation/types.pb.h" 35 #include "google/cacheinvalidation/types.pb.h"
35 #include "webkit/fileapi/file_system_context.h" 36 #include "webkit/fileapi/file_system_context.h"
36 #include "webkit/fileapi/file_system_mount_point_provider.h" 37 #include "webkit/fileapi/file_system_mount_point_provider.h"
37 38
38 using content::BrowserContext; 39 using content::BrowserContext;
39 using content::BrowserThread; 40 using content::BrowserThread;
40 41
41 namespace drive { 42 namespace drive {
42 namespace { 43 namespace {
43 44
45 static const size_t kEventLogHistorySize = 100;
46
44 // Used in test to setup system service. 47 // Used in test to setup system service.
45 google_apis::DriveServiceInterface* g_test_drive_service = NULL; 48 google_apis::DriveServiceInterface* g_test_drive_service = NULL;
46 const std::string* g_test_cache_root = NULL; 49 const std::string* g_test_cache_root = NULL;
47 50
48 // Returns true if Drive is enabled for the given Profile. 51 // Returns true if Drive is enabled for the given Profile.
49 bool IsDriveEnabledForProfile(Profile* profile) { 52 bool IsDriveEnabledForProfile(Profile* profile) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 54
52 if (!google_apis::AuthService::CanAuthenticate(profile)) 55 if (!google_apis::AuthService::CanAuthenticate(profile))
53 return false; 56 return false;
(...skipping 27 matching lines...) Expand all
81 DriveSystemService::~DriveSystemService() { 84 DriveSystemService::~DriveSystemService() {
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
83 cache_->Destroy(); 86 cache_->Destroy();
84 } 87 }
85 88
86 void DriveSystemService::Initialize( 89 void DriveSystemService::Initialize(
87 google_apis::DriveServiceInterface* drive_service, 90 google_apis::DriveServiceInterface* drive_service,
88 const FilePath& cache_root) { 91 const FilePath& cache_root) {
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
90 93
94 event_logger_.reset(new EventLogger(kEventLogHistorySize));
91 drive_service_.reset(drive_service); 95 drive_service_.reset(drive_service);
92 cache_ = DriveCache::CreateDriveCache(cache_root, blocking_task_runner_); 96 cache_ = DriveCache::CreateDriveCache(cache_root, blocking_task_runner_);
93 uploader_.reset(new google_apis::DriveUploader(drive_service_.get())); 97 uploader_.reset(new google_apis::DriveUploader(drive_service_.get()));
94 webapps_registry_.reset(new DriveWebAppsRegistry); 98 webapps_registry_.reset(new DriveWebAppsRegistry);
95 file_system_.reset(new DriveFileSystem(profile_, 99 file_system_.reset(new DriveFileSystem(profile_,
96 cache(), 100 cache(),
97 drive_service_.get(), 101 drive_service_.get(),
98 uploader(), 102 uploader(),
99 webapps_registry(), 103 webapps_registry(),
100 blocking_task_runner_)); 104 blocking_task_runner_));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 217 }
214 218
215 void DriveSystemService::AddDriveMountPoint() { 219 void DriveSystemService::AddDriveMountPoint() {
216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
217 221
218 const FilePath mount_point = util::GetDriveMountPointPath(); 222 const FilePath mount_point = util::GetDriveMountPointPath();
219 fileapi::ExternalFileSystemMountPointProvider* provider = 223 fileapi::ExternalFileSystemMountPointProvider* provider =
220 BrowserContext::GetDefaultStoragePartition(profile_)-> 224 BrowserContext::GetDefaultStoragePartition(profile_)->
221 GetFileSystemContext()->external_provider(); 225 GetFileSystemContext()->external_provider();
222 if (provider && !provider->HasMountPoint(mount_point)) { 226 if (provider && !provider->HasMountPoint(mount_point)) {
227 event_logger_->Log("AddDriveMountPoint");
223 provider->AddRemoteMountPoint( 228 provider->AddRemoteMountPoint(
224 mount_point, 229 mount_point,
225 new DriveFileSystemProxy(file_system_.get())); 230 new DriveFileSystemProxy(file_system_.get()));
226 } 231 }
227 232
228 file_system_->NotifyFileSystemMounted(); 233 file_system_->NotifyFileSystemMounted();
229 } 234 }
230 235
231 void DriveSystemService::RemoveDriveMountPoint() { 236 void DriveSystemService::RemoveDriveMountPoint() {
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
233 238
234 file_system_->NotifyFileSystemToBeUnmounted(); 239 file_system_->NotifyFileSystemToBeUnmounted();
235 file_system_->StopPolling(); 240 file_system_->StopPolling();
236 241
237 const FilePath mount_point = util::GetDriveMountPointPath(); 242 const FilePath mount_point = util::GetDriveMountPointPath();
238 fileapi::ExternalFileSystemMountPointProvider* provider = 243 fileapi::ExternalFileSystemMountPointProvider* provider =
239 BrowserContext::GetDefaultStoragePartition(profile_)-> 244 BrowserContext::GetDefaultStoragePartition(profile_)->
240 GetFileSystemContext()->external_provider(); 245 GetFileSystemContext()->external_provider();
241 if (provider && provider->HasMountPoint(mount_point)) 246 if (provider && provider->HasMountPoint(mount_point)) {
242 provider->RemoveMountPoint(mount_point); 247 provider->RemoveMountPoint(mount_point);
248 event_logger_->Log("RemoveDriveMountPoint");
249 }
243 } 250 }
244 251
245 void DriveSystemService::OnCacheInitialized(bool success) { 252 void DriveSystemService::OnCacheInitialized(bool success) {
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
247 254
248 if (!success) { 255 if (!success) {
249 LOG(WARNING) << "Failed to initialize the cache. Disabling Drive"; 256 LOG(WARNING) << "Failed to initialize the cache. Disabling Drive";
250 DisableDrive(); 257 DisableDrive();
251 return; 258 return;
252 } 259 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 g_test_cache_root ? FilePath(*g_test_cache_root) : 375 g_test_cache_root ? FilePath(*g_test_cache_root) :
369 DriveCache::GetCacheRootPath(profile); 376 DriveCache::GetCacheRootPath(profile);
370 delete g_test_cache_root; 377 delete g_test_cache_root;
371 g_test_cache_root = NULL; 378 g_test_cache_root = NULL;
372 379
373 service->Initialize(drive_service, cache_root); 380 service->Initialize(drive_service, cache_root);
374 return service; 381 return service;
375 } 382 }
376 383
377 } // namespace drive 384 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698