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

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

Issue 11343004: drive: Add "Delta Update Status" section to chrome:drive-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: polish 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_file_system.h" 5 #include "chrome/browser/chromeos/drive/drive_file_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 google_apis::DriveServiceInterface* drive_service, 369 google_apis::DriveServiceInterface* drive_service,
370 google_apis::DriveUploaderInterface* uploader, 370 google_apis::DriveUploaderInterface* uploader,
371 DriveWebAppsRegistryInterface* webapps_registry, 371 DriveWebAppsRegistryInterface* webapps_registry,
372 base::SequencedTaskRunner* blocking_task_runner) 372 base::SequencedTaskRunner* blocking_task_runner)
373 : profile_(profile), 373 : profile_(profile),
374 cache_(cache), 374 cache_(cache),
375 uploader_(uploader), 375 uploader_(uploader),
376 drive_service_(drive_service), 376 drive_service_(drive_service),
377 webapps_registry_(webapps_registry), 377 webapps_registry_(webapps_registry),
378 update_timer_(true /* retain_user_task */, true /* is_repeating */), 378 update_timer_(true /* retain_user_task */, true /* is_repeating */),
379 last_update_check_error_(DRIVE_FILE_OK),
379 hide_hosted_docs_(false), 380 hide_hosted_docs_(false),
380 blocking_task_runner_(blocking_task_runner), 381 blocking_task_runner_(blocking_task_runner),
381 scheduler_(new DriveScheduler(profile, &drive_operations_)), 382 scheduler_(new DriveScheduler(profile, &drive_operations_)),
382 ALLOW_THIS_IN_INITIALIZER_LIST(ui_weak_ptr_factory_(this)), 383 ALLOW_THIS_IN_INITIALIZER_LIST(ui_weak_ptr_factory_(this)),
383 ui_weak_ptr_(ui_weak_ptr_factory_.GetWeakPtr()), 384 ui_weak_ptr_(ui_weak_ptr_factory_.GetWeakPtr()),
384 polling_interval_sec_(kFastPollingIntervalInSec) { 385 polling_interval_sec_(kFastPollingIntervalInSec) {
385 // Should be created from the file browser extension API on UI thread. 386 // Should be created from the file browser extension API on UI thread.
386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
387 } 388 }
388 389
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 !feed_loader_->refreshing()) { 440 !feed_loader_->refreshing()) {
440 feed_loader_->ReloadFromServerIfNeeded( 441 feed_loader_->ReloadFromServerIfNeeded(
441 resource_metadata_->largest_changestamp(), 442 resource_metadata_->largest_changestamp(),
442 base::Bind(&DriveFileSystem::OnUpdateChecked, ui_weak_ptr_)); 443 base::Bind(&DriveFileSystem::OnUpdateChecked, ui_weak_ptr_));
443 } 444 }
444 } 445 }
445 446
446 void DriveFileSystem::OnUpdateChecked(DriveFileError error) { 447 void DriveFileSystem::OnUpdateChecked(DriveFileError error) {
447 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
448 DVLOG(1) << "CheckForUpdates finished: " << error; 449 DVLOG(1) << "CheckForUpdates finished: " << error;
450 last_update_check_time_ = base::Time::Now();
451 last_update_check_error_ = error;
449 } 452 }
450 453
451 DriveFileSystem::~DriveFileSystem() { 454 DriveFileSystem::~DriveFileSystem() {
452 // This should be called from UI thread, from DriveSystemService shutdown. 455 // This should be called from UI thread, from DriveSystemService shutdown.
453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
454 457
455 feed_loader_->RemoveObserver(this); 458 feed_loader_->RemoveObserver(this);
456 459
457 // Cancel all the in-flight operations. 460 // Cancel all the in-flight operations.
458 // This asynchronously cancels the URL fetch operations. 461 // This asynchronously cancels the URL fetch operations.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 // DriveSystemService::RemoveDriveMountPoint(), this will be called again from 503 // DriveSystemService::RemoveDriveMountPoint(), this will be called again from
501 // FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(). 504 // FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread().
502 // We choose to stopping updates asynchronous without waiting for filemanager, 505 // We choose to stopping updates asynchronous without waiting for filemanager,
503 // rather than waiting for completion of unmounting on filemanager. 506 // rather than waiting for completion of unmounting on filemanager.
504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
505 if (update_timer_.IsRunning()) 508 if (update_timer_.IsRunning())
506 update_timer_.Stop(); 509 update_timer_.Stop();
507 } 510 }
508 511
509 void DriveFileSystem::SetPushNotificationEnabled(bool enabled) { 512 void DriveFileSystem::SetPushNotificationEnabled(bool enabled) {
513 push_notification_enabled_ = enabled;
510 polling_interval_sec_ = enabled ? kSlowPollingIntervalInSec : 514 polling_interval_sec_ = enabled ? kSlowPollingIntervalInSec :
511 kFastPollingIntervalInSec; 515 kFastPollingIntervalInSec;
512 } 516 }
513 517
514 void DriveFileSystem::GetEntryInfoByResourceId( 518 void DriveFileSystem::GetEntryInfoByResourceId(
515 const std::string& resource_id, 519 const std::string& resource_id,
516 const GetEntryInfoWithFilePathCallback& callback) { 520 const GetEntryInfoWithFilePathCallback& callback) {
517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
518 BrowserThread::CurrentlyOn(BrowserThread::IO)); 522 BrowserThread::CurrentlyOn(BrowserThread::IO));
519 DCHECK(!callback.is_null()); 523 DCHECK(!callback.is_null());
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 base::Bind(&OnCacheUpdatedForAddUploadedFile, 2160 base::Bind(&OnCacheUpdatedForAddUploadedFile,
2157 params.callback)); 2161 params.callback));
2158 } 2162 }
2159 2163
2160 DriveFileSystemMetadata DriveFileSystem::GetMetadata() const { 2164 DriveFileSystemMetadata DriveFileSystem::GetMetadata() const {
2161 DriveFileSystemMetadata metadata; 2165 DriveFileSystemMetadata metadata;
2162 metadata.largest_changestamp = resource_metadata_->largest_changestamp(); 2166 metadata.largest_changestamp = resource_metadata_->largest_changestamp();
2163 metadata.origin = ContentOriginToString(resource_metadata_->origin()); 2167 metadata.origin = ContentOriginToString(resource_metadata_->origin());
2164 if (feed_loader_->refreshing()) 2168 if (feed_loader_->refreshing())
2165 metadata.origin += " (refreshing)"; 2169 metadata.origin += " (refreshing)";
2170
2171 // Metadata related to delta update.
2172 metadata.push_notification_enabled = push_notification_enabled_;
2173 metadata.polling_interval_sec = polling_interval_sec_;
2174 metadata.last_update_check_time = last_update_check_time_;
2175 metadata.last_update_check_error = last_update_check_error_;
2176
2166 return metadata; 2177 return metadata;
2167 } 2178 }
2168 2179
2169 void DriveFileSystem::Observe(int type, 2180 void DriveFileSystem::Observe(int type,
2170 const content::NotificationSource& source, 2181 const content::NotificationSource& source,
2171 const content::NotificationDetails& details) { 2182 const content::NotificationDetails& details) {
2172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2173 2184
2174 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 2185 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
2175 PrefService* pref_service = profile_->GetPrefs(); 2186 PrefService* pref_service = profile_->GetPrefs();
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 return; 2541 return;
2531 } 2542 }
2532 2543
2533 PlatformFileInfoProto entry_file_info; 2544 PlatformFileInfoProto entry_file_info;
2534 DriveEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 2545 DriveEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
2535 *entry_proto->mutable_file_info() = entry_file_info; 2546 *entry_proto->mutable_file_info() = entry_file_info;
2536 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); 2547 callback.Run(DRIVE_FILE_OK, entry_proto.Pass());
2537 } 2548 }
2538 2549
2539 } // namespace drive 2550 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698