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

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

Issue 20609006: Add severity info to drive::EventLogger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 #include "chrome/browser/chromeos/drive/change_list_loader.h" 5 #include "chrome/browser/chromeos/drive/change_list_loader.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // There is in-flight loading. So keep the callback here, and check for 65 // There is in-flight loading. So keep the callback here, and check for
66 // updates when the in-flight loading is completed. 66 // updates when the in-flight loading is completed.
67 pending_update_check_callback_ = callback; 67 pending_update_check_callback_ = callback;
68 return; 68 return;
69 } 69 }
70 70
71 if (loaded_) { 71 if (loaded_) {
72 // We only start to check for updates iff the load is done. 72 // We only start to check for updates iff the load is done.
73 // I.e., we ignore checking updates if not loaded to avoid starting the 73 // I.e., we ignore checking updates if not loaded to avoid starting the
74 // load without user's explicit interaction (such as opening Drive). 74 // load without user's explicit interaction (such as opening Drive).
75 util::Log("Checking for updates"); 75 util::Log(logging::LOG_INFO, "Checking for updates");
76 Load(DirectoryFetchInfo(), callback); 76 Load(DirectoryFetchInfo(), callback);
77 } 77 }
78 } 78 }
79 79
80 void ChangeListLoader::LoadIfNeeded( 80 void ChangeListLoader::LoadIfNeeded(
81 const DirectoryFetchInfo& directory_fetch_info, 81 const DirectoryFetchInfo& directory_fetch_info,
82 const FileOperationCallback& callback) { 82 const FileOperationCallback& callback) {
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
84 DCHECK(!callback.is_null()); 84 DCHECK(!callback.is_null());
85 85
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 Load(DirectoryFetchInfo(), 205 Load(DirectoryFetchInfo(),
206 base::ResetAndReturn(&pending_update_check_callback_)); 206 base::ResetAndReturn(&pending_update_check_callback_));
207 } 207 }
208 } 208 }
209 209
210 void ChangeListLoader::OnDirectoryLoadComplete( 210 void ChangeListLoader::OnDirectoryLoadComplete(
211 const DirectoryFetchInfo& directory_fetch_info, 211 const DirectoryFetchInfo& directory_fetch_info,
212 FileError error) { 212 FileError error) {
213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
214 214
215 util::Log("Fast-fetch complete: %s => %s", 215 util::Log(logging::LOG_INFO,
216 "Fast-fetch complete: %s => %s",
216 directory_fetch_info.ToString().c_str(), 217 directory_fetch_info.ToString().c_str(),
217 FileErrorToString(error).c_str()); 218 FileErrorToString(error).c_str());
218 const std::string& resource_id = directory_fetch_info.resource_id(); 219 const std::string& resource_id = directory_fetch_info.resource_id();
219 LoadCallbackMap::iterator it = pending_load_callback_.find(resource_id); 220 LoadCallbackMap::iterator it = pending_load_callback_.find(resource_id);
220 if (it != pending_load_callback_.end()) { 221 if (it != pending_load_callback_.end()) {
221 DVLOG(1) << "Running callback for " << resource_id; 222 DVLOG(1) << "Running callback for " << resource_id;
222 const std::vector<FileOperationCallback>& callbacks = it->second; 223 const std::vector<FileOperationCallback>& callbacks = it->second;
223 for (size_t i = 0; i < callbacks.size(); ++i) { 224 for (size_t i = 0; i < callbacks.size(); ++i) {
224 base::MessageLoopProxy::current()->PostTask( 225 base::MessageLoopProxy::current()->PostTask(
225 FROM_HERE, 226 FROM_HERE,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
434 DCHECK(!directory_fetch_info.empty()); 435 DCHECK(!directory_fetch_info.empty());
435 436
436 int64 directory_changestamp = std::max(directory_fetch_info.changestamp(), 437 int64 directory_changestamp = std::max(directory_fetch_info.changestamp(),
437 local_changestamp); 438 local_changestamp);
438 439
439 // We may not fetch from the server at all if the local metadata is new 440 // We may not fetch from the server at all if the local metadata is new
440 // enough, but we log this message here, so "Fast-fetch start" and 441 // enough, but we log this message here, so "Fast-fetch start" and
441 // "Fast-fetch complete" always match. 442 // "Fast-fetch complete" always match.
442 // TODO(satorux): Distinguish the "not fetching at all" case. 443 // TODO(satorux): Distinguish the "not fetching at all" case.
443 util::Log("Fast-fetch start: %s; Server changestamp: %s", 444 util::Log(logging::LOG_INFO,
445 "Fast-fetch start: %s; Server changestamp: %s",
444 directory_fetch_info.ToString().c_str(), 446 directory_fetch_info.ToString().c_str(),
445 base::Int64ToString(last_known_remote_changestamp_).c_str()); 447 base::Int64ToString(last_known_remote_changestamp_).c_str());
446 448
447 // If the directory's changestamp is up-to-date, just schedule to run the 449 // If the directory's changestamp is up-to-date, just schedule to run the
448 // callback, as there is no need to fetch the directory. 450 // callback, as there is no need to fetch the directory.
449 // Note that |last_known_remote_changestamp_| is 0 when it is not received 451 // Note that |last_known_remote_changestamp_| is 0 when it is not received
450 // yet. In that case we conservatively assume that we need to fetch. 452 // yet. In that case we conservatively assume that we need to fetch.
451 if (last_known_remote_changestamp_ > 0 && 453 if (last_known_remote_changestamp_ > 0 &&
452 directory_changestamp >= last_known_remote_changestamp_) { 454 directory_changestamp >= last_known_remote_changestamp_) {
453 callback.Run(FILE_ERROR_OK); 455 callback.Run(FILE_ERROR_OK);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 const base::Closure& callback) { 625 const base::Closure& callback) {
624 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 626 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
625 DCHECK(!callback.is_null()); 627 DCHECK(!callback.is_null());
626 628
627 ChangeListProcessor* change_list_processor = 629 ChangeListProcessor* change_list_processor =
628 new ChangeListProcessor(resource_metadata_); 630 new ChangeListProcessor(resource_metadata_);
629 // Don't send directory content change notification while performing 631 // Don't send directory content change notification while performing
630 // the initial content retrieval. 632 // the initial content retrieval.
631 const bool should_notify_changed_directories = is_delta_update; 633 const bool should_notify_changed_directories = is_delta_update;
632 634
633 util::Log("Apply change lists (is delta: %d)", is_delta_update); 635 util::Log(logging::LOG_INFO,
636 "Apply change lists (is delta: %d)",
637 is_delta_update);
634 blocking_task_runner_->PostTaskAndReply( 638 blocking_task_runner_->PostTaskAndReply(
635 FROM_HERE, 639 FROM_HERE,
636 base::Bind(&ChangeListProcessor::Apply, 640 base::Bind(&ChangeListProcessor::Apply,
637 base::Unretained(change_list_processor), 641 base::Unretained(change_list_processor),
638 base::Passed(&about_resource), 642 base::Passed(&about_resource),
639 base::Passed(&change_lists), 643 base::Passed(&change_lists),
640 is_delta_update), 644 is_delta_update),
641 base::Bind(&ChangeListLoader::UpdateFromChangeListAfterApply, 645 base::Bind(&ChangeListLoader::UpdateFromChangeListAfterApply,
642 weak_ptr_factory_.GetWeakPtr(), 646 weak_ptr_factory_.GetWeakPtr(),
643 base::Owned(change_list_processor), 647 base::Owned(change_list_processor),
644 should_notify_changed_directories, 648 should_notify_changed_directories,
645 base::Time::Now(), 649 base::Time::Now(),
646 callback)); 650 callback));
647 } 651 }
648 652
649 void ChangeListLoader::UpdateFromChangeListAfterApply( 653 void ChangeListLoader::UpdateFromChangeListAfterApply(
650 ChangeListProcessor* change_list_processor, 654 ChangeListProcessor* change_list_processor,
651 bool should_notify_changed_directories, 655 bool should_notify_changed_directories,
652 base::Time start_time, 656 base::Time start_time,
653 const base::Closure& callback) { 657 const base::Closure& callback) {
654 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
655 DCHECK(change_list_processor); 659 DCHECK(change_list_processor);
656 DCHECK(!callback.is_null()); 660 DCHECK(!callback.is_null());
657 661
658 const base::TimeDelta elapsed = base::Time::Now() - start_time; 662 const base::TimeDelta elapsed = base::Time::Now() - start_time;
659 util::Log("Change lists applied (elapsed time: %sms)", 663 util::Log(logging::LOG_INFO,
664 "Change lists applied (elapsed time: %sms)",
660 base::Int64ToString(elapsed.InMilliseconds()).c_str()); 665 base::Int64ToString(elapsed.InMilliseconds()).c_str());
661 666
662 if (should_notify_changed_directories) { 667 if (should_notify_changed_directories) {
663 for (std::set<base::FilePath>::iterator dir_iter = 668 for (std::set<base::FilePath>::iterator dir_iter =
664 change_list_processor->changed_dirs().begin(); 669 change_list_processor->changed_dirs().begin();
665 dir_iter != change_list_processor->changed_dirs().end(); 670 dir_iter != change_list_processor->changed_dirs().end();
666 ++dir_iter) { 671 ++dir_iter) {
667 FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_, 672 FOR_EACH_OBSERVER(ChangeListLoaderObserver, observers_,
668 OnDirectoryChanged(*dir_iter)); 673 OnDirectoryChanged(*dir_iter));
669 } 674 }
670 } 675 }
671 676
672 callback.Run(); 677 callback.Run();
673 } 678 }
674 679
675 } // namespace internal 680 } // namespace internal
676 } // namespace drive 681 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_integration_service.cc » ('j') | chrome/browser/drive/event_logger.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698