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

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

Issue 439643003: Change AboutResourceLoader::GetAboutResource to wait for inflight update task. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_loader_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/directory_loader.h" 5 #include "chrome/browser/chromeos/drive/directory_loader.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 const std::string& local_id = directory_fetch_info.local_id(); 291 const std::string& local_id = directory_fetch_info.local_id();
292 ReadDirectoryCallbackState callback_state; 292 ReadDirectoryCallbackState callback_state;
293 callback_state.entries_callback = entries_callback; 293 callback_state.entries_callback = entries_callback;
294 callback_state.completion_callback = completion_callback; 294 callback_state.completion_callback = completion_callback;
295 pending_load_callback_[local_id].push_back(callback_state); 295 pending_load_callback_[local_id].push_back(callback_state);
296 296
297 // If loading task for |local_id| is already running, do nothing. 297 // If loading task for |local_id| is already running, do nothing.
298 if (pending_load_callback_[local_id].size() > 1) 298 if (pending_load_callback_[local_id].size() > 1)
299 return; 299 return;
300 300
301 // Note: To be precise, we need to call UpdateAboutResource() here. However,
302 // - It is costly to do GetAboutResource HTTP request every time.
303 // - The chance using an old value is small; it only happens when
304 // ReadDirectory is called during one GetAboutResource roundtrip time
305 // of a change list fetching.
306 // - Even if the value is old, it just marks the directory as older. It may
307 // trigger one future unnecessary re-fetch, but it'll never lose data.
308 about_resource_loader_->GetAboutResource( 301 about_resource_loader_->GetAboutResource(
309 base::Bind(&DirectoryLoader::ReadDirectoryAfterGetAboutResource, 302 base::Bind(&DirectoryLoader::ReadDirectoryAfterGetAboutResource,
310 weak_ptr_factory_.GetWeakPtr(), local_id)); 303 weak_ptr_factory_.GetWeakPtr(), local_id));
311 } 304 }
312 305
313 void DirectoryLoader::ReadDirectoryAfterLoadParent( 306 void DirectoryLoader::ReadDirectoryAfterLoadParent(
314 const base::FilePath& directory_path, 307 const base::FilePath& directory_path,
315 const ReadDirectoryEntriesCallback& entries_callback, 308 const ReadDirectoryEntriesCallback& entries_callback,
316 const FileOperationCallback& completion_callback, 309 const FileOperationCallback& completion_callback,
317 FileError error) { 310 FileError error) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // Also notify the observers. 561 // Also notify the observers.
569 if (error == FILE_ERROR_OK && !directory_path->empty()) { 562 if (error == FILE_ERROR_OK && !directory_path->empty()) {
570 FOR_EACH_OBSERVER(ChangeListLoaderObserver, 563 FOR_EACH_OBSERVER(ChangeListLoaderObserver,
571 observers_, 564 observers_,
572 OnDirectoryReloaded(*directory_path)); 565 OnDirectoryReloaded(*directory_path));
573 } 566 }
574 } 567 }
575 568
576 } // namespace internal 569 } // namespace internal
577 } // namespace drive 570 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_loader_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698