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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 10835031: gdata: Trigger delta feed when search results contained unknown entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 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 | « no previous file | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc » ('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/gdata/gdata_file_system.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (relay_proxy->BelongsToCurrentThread()) { 399 if (relay_proxy->BelongsToCurrentThread()) {
400 task.Run(); 400 task.Run();
401 } else { 401 } else {
402 const bool posted = relay_proxy->PostTask(FROM_HERE, task); 402 const bool posted = relay_proxy->PostTask(FROM_HERE, task);
403 DCHECK(posted); 403 DCHECK(posted);
404 } 404 }
405 } 405 }
406 406
407 // Callback for GetEntryByResourceIdAsync. 407 // Callback for GetEntryByResourceIdAsync.
408 // Adds |entry| to |results|. Runs |callback| with |results| when 408 // Adds |entry| to |results|. Runs |callback| with |results| when
409 // |run_callback| is true. 409 // |run_callback| is true. When |entry| is not present in our local file system
410 // snapshot, it is not added to |results|. Instead, |entry_skipped_callback| is
411 // called.
410 void AddEntryToSearchResults( 412 void AddEntryToSearchResults(
411 std::vector<SearchResultInfo>* results, 413 std::vector<SearchResultInfo>* results,
412 const SearchCallback& callback, 414 const SearchCallback& callback,
415 const base::Closure& entry_skipped_callback,
413 GDataFileError error, 416 GDataFileError error,
414 bool run_callback, 417 bool run_callback,
415 GDataEntry* entry) { 418 GDataEntry* entry) {
416 // If a result is not present in our local file system snapshot, ignore it. 419 // If a result is not present in our local file system snapshot, invoke
420 // |entry_skipped_callback| and refreshes the snapshot with delta feed.
417 // For example, this may happen if the entry has recently been added to the 421 // For example, this may happen if the entry has recently been added to the
418 // drive (and we still haven't received its delta feed). 422 // drive (and we still haven't received its delta feed).
419 if (entry) { 423 if (entry) {
420 const bool is_directory = entry->AsGDataDirectory() != NULL; 424 const bool is_directory = entry->AsGDataDirectory() != NULL;
421 results->push_back(SearchResultInfo(entry->GetFilePath(), is_directory)); 425 results->push_back(SearchResultInfo(entry->GetFilePath(), is_directory));
426 } else {
427 if (!entry_skipped_callback.is_null())
428 entry_skipped_callback.Run();
422 } 429 }
423 430
424 if (run_callback) { 431 if (run_callback) {
425 scoped_ptr<std::vector<SearchResultInfo> > result_vec(results); 432 scoped_ptr<std::vector<SearchResultInfo> > result_vec(results);
426 if (!callback.is_null()) 433 if (!callback.is_null())
427 callback.Run(error, result_vec.Pass()); 434 callback.Run(error, result_vec.Pass());
428 } 435 }
429 } 436 }
430 437
431 // Runs task on UI thread. 438 // Runs task on UI thread.
(...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 } 2791 }
2785 2792
2786 // We will need information about result entry to create info for callback. 2793 // We will need information about result entry to create info for callback.
2787 // We can't use |entry| anymore, so we have to refetch entry from file 2794 // We can't use |entry| anymore, so we have to refetch entry from file
2788 // system. Also, |entry| doesn't have file path set before |RefreshFile| 2795 // system. Also, |entry| doesn't have file path set before |RefreshFile|
2789 // call, so we can't get file path from there. 2796 // call, so we can't get file path from there.
2790 directory_service_->GetEntryByResourceIdAsync(entry_resource_id, 2797 directory_service_->GetEntryByResourceIdAsync(entry_resource_id,
2791 base::Bind(&AddEntryToSearchResults, 2798 base::Bind(&AddEntryToSearchResults,
2792 results, 2799 results,
2793 callback, 2800 callback,
2801 base::Bind(&GDataFileSystem::CheckForUpdates, ui_weak_ptr_),
2794 error, 2802 error,
2795 i+1 == feed->entries().size())); 2803 i+1 == feed->entries().size()));
2796 } 2804 }
2797 } 2805 }
2798 2806
2799 void GDataFileSystem::Search(const std::string& search_query, 2807 void GDataFileSystem::Search(const std::string& search_query,
2800 const SearchCallback& callback) { 2808 const SearchCallback& callback) {
2801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 2809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
2802 BrowserThread::CurrentlyOn(BrowserThread::IO)); 2810 BrowserThread::CurrentlyOn(BrowserThread::IO));
2803 RunTaskOnUIThread(base::Bind(&GDataFileSystem::SearchAsyncOnUIThread, 2811 RunTaskOnUIThread(base::Bind(&GDataFileSystem::SearchAsyncOnUIThread,
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
4358 } 4366 }
4359 4367
4360 PlatformFileInfoProto entry_file_info; 4368 PlatformFileInfoProto entry_file_info;
4361 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 4369 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
4362 *entry_proto->mutable_file_info() = entry_file_info; 4370 *entry_proto->mutable_file_info() = entry_file_info;
4363 if (!callback.is_null()) 4371 if (!callback.is_null())
4364 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 4372 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
4365 } 4373 }
4366 4374
4367 } // namespace gdata 4375 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698