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

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

Issue 14247011: drive: Change EventLogger to take printf format (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/event_logger.h » ('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 #include "chrome/browser/chromeos/drive/drive_prefetcher.h" 5 #include "chrome/browser/chromeos/drive/drive_prefetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" 10 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // Scans the filesystem. When it is finished, DoPrefetch() will be called. 97 // Scans the filesystem. When it is finished, DoPrefetch() will be called.
98 VisitDirectory(util::GetDriveMyDriveRootPath()); 98 VisitDirectory(util::GetDriveMyDriveRootPath());
99 } 99 }
100 100
101 void DrivePrefetcher::DoPrefetch() { 101 void DrivePrefetcher::DoPrefetch() {
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
103 103
104 for (LatestFileSet::reverse_iterator it = latest_files_.rbegin(); 104 for (LatestFileSet::reverse_iterator it = latest_files_.rbegin();
105 it != latest_files_.rend(); ++it) { 105 it != latest_files_.rend(); ++it) {
106 const std::string& resource_id = it->resource_id(); 106 const std::string& resource_id = it->resource_id();
107 event_logger_->Log("Prefetcher: Enqueue prefetching " + resource_id); 107 event_logger_->Log("Prefetcher: Enqueue prefetching %s",
108 resource_id.c_str());
108 file_system_->GetFileByResourceId( 109 file_system_->GetFileByResourceId(
109 resource_id, 110 resource_id,
110 DriveClientContext(PREFETCH), 111 DriveClientContext(PREFETCH),
111 base::Bind(&DrivePrefetcher::OnPrefetchFinished, 112 base::Bind(&DrivePrefetcher::OnPrefetchFinished,
112 weak_ptr_factory_.GetWeakPtr(), 113 weak_ptr_factory_.GetWeakPtr(),
113 resource_id), 114 resource_id),
114 google_apis::GetContentCallback()); 115 google_apis::GetContentCallback());
115 } 116 }
116 } 117 }
117 118
118 void DrivePrefetcher::OnPrefetchFinished(const std::string& resource_id, 119 void DrivePrefetcher::OnPrefetchFinished(const std::string& resource_id,
119 DriveFileError error, 120 DriveFileError error,
120 const base::FilePath& file_path, 121 const base::FilePath& file_path,
121 const std::string& mime_type, 122 const std::string& mime_type,
122 DriveFileType file_type) { 123 DriveFileType file_type) {
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
124 if (error != DRIVE_FILE_OK) 125 if (error != DRIVE_FILE_OK)
125 LOG(WARNING) << "Prefetch failed: " << DriveFileErrorToString(error); 126 LOG(WARNING) << "Prefetch failed: " << DriveFileErrorToString(error);
126 event_logger_->Log(base::StringPrintf("Prefetcher: Finish fetching (%s) %s", 127 event_logger_->Log("Prefetcher: Finish fetching (%s) %s",
127 DriveFileErrorToString(error).c_str(), 128 DriveFileErrorToString(error).c_str(),
128 resource_id.c_str())); 129 resource_id.c_str());
129 } 130 }
130 131
131 void DrivePrefetcher::VisitFile(const DriveEntryProto& entry) { 132 void DrivePrefetcher::VisitFile(const DriveEntryProto& entry) {
132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
133 134
134 // Excessively large files will not be fetched. 135 // Excessively large files will not be fetched.
135 if (entry.file_info().size() > prefetch_file_size_limit_) 136 if (entry.file_info().size() > prefetch_file_size_limit_)
136 return; 137 return;
137 138
138 // Remember the file in the set ordered by the |last_accessed| field. 139 // Remember the file in the set ordered by the |last_accessed| field.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 187
187 void DrivePrefetcher::OnReadDirectoryFinished() { 188 void DrivePrefetcher::OnReadDirectoryFinished() {
188 DCHECK(number_of_inflight_traversals_ > 0); 189 DCHECK(number_of_inflight_traversals_ > 0);
189 190
190 --number_of_inflight_traversals_; 191 --number_of_inflight_traversals_;
191 if (number_of_inflight_traversals_ == 0) 192 if (number_of_inflight_traversals_ == 0)
192 DoPrefetch(); // Start prefetching. 193 DoPrefetch(); // Start prefetching.
193 } 194 }
194 195
195 } // namespace drive 196 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/event_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698