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

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

Issue 10824303: gdata: Remove FindEntryByPathAndRunSync() from GDataWapiFeedLoader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 initial_origin, 553 initial_origin,
554 directory_service_->largest_changestamp(), 554 directory_service_->largest_changestamp(),
555 directory_service_->root()->GetFilePath(), 555 directory_service_->root()->GetFilePath(),
556 base::Bind(&GDataFileSystem::OnUpdateChecked, 556 base::Bind(&GDataFileSystem::OnUpdateChecked,
557 ui_weak_ptr_, 557 ui_weak_ptr_,
558 initial_origin)); 558 initial_origin));
559 } 559 }
560 } 560 }
561 561
562 void GDataFileSystem::OnUpdateChecked(ContentOrigin initial_origin, 562 void GDataFileSystem::OnUpdateChecked(ContentOrigin initial_origin,
563 GDataFileError error, 563 GDataFileError error) {
564 GDataEntry* /* entry */) {
565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
566 565
567 if (error != GDATA_FILE_OK) { 566 if (error != GDATA_FILE_OK)
568 directory_service_->set_origin(initial_origin); 567 directory_service_->set_origin(initial_origin);
569 }
570 } 568 }
571 569
572 GDataFileSystem::~GDataFileSystem() { 570 GDataFileSystem::~GDataFileSystem() {
573 // This should be called from UI thread, from GDataSystemService shutdown. 571 // This should be called from UI thread, from GDataSystemService shutdown.
574 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
575 573
576 feed_loader_->RemoveObserver(this); 574 feed_loader_->RemoveObserver(this);
577 575
578 // Cancel all the in-flight operations. 576 // Cancel all the in-flight operations.
579 // This asynchronously cancels the URL fetch operations. 577 // This asynchronously cancels the URL fetch operations.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 callback))); 678 callback)));
681 return; 679 return;
682 } else if (directory_service_->origin() == UNINITIALIZED) { 680 } else if (directory_service_->origin() == UNINITIALIZED) {
683 // Load root feed from this disk cache. Upon completion, kick off server 681 // Load root feed from this disk cache. Upon completion, kick off server
684 // fetching. 682 // fetching.
685 directory_service_->set_origin(INITIALIZING); 683 directory_service_->set_origin(INITIALIZING);
686 feed_loader_->LoadFromCache( 684 feed_loader_->LoadFromCache(
687 true, // should_load_from_server 685 true, // should_load_from_server
688 search_file_path, 686 search_file_path,
689 // This is the initial load, hence we'll notify when it's done. 687 // This is the initial load, hence we'll notify when it's done.
690 base::Bind(&GDataFileSystem::RunAndNotifyInitialLoadFinished, 688 base::Bind(&GDataFileSystem::FindAndNotifyInitialLoadFinished,
691 ui_weak_ptr_, 689 ui_weak_ptr_,
690 search_file_path,
692 callback)); 691 callback));
693 return; 692 return;
694 } 693 }
695 694
696 // Post a task to the same thread, rather than calling it here, as 695 // Post a task to the same thread, rather than calling it here, as
697 // FindEntryByPath() is asynchronous. 696 // FindEntryByPath() is asynchronous.
698 base::MessageLoopProxy::current()->PostTask( 697 base::MessageLoopProxy::current()->PostTask(
699 FROM_HERE, 698 FROM_HERE,
700 base::Bind(&GDataFileSystem::FindEntryByPathSyncOnUIThread, 699 base::Bind(&GDataFileSystem::FindEntryByPathSyncOnUIThread,
701 ui_weak_ptr_, 700 ui_weak_ptr_,
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 2002
2004 feed_loader_->LoadFromServer( 2003 feed_loader_->LoadFromServer(
2005 directory_service_->origin(), 2004 directory_service_->origin(),
2006 0, // Not delta feed. 2005 0, // Not delta feed.
2007 0, // Not used. 2006 0, // Not used.
2008 true, // multiple feeds 2007 true, // multiple feeds
2009 file_path, 2008 file_path,
2010 std::string(), // No search query 2009 std::string(), // No search query
2011 GURL(), /* feed not explicitly set */ 2010 GURL(), /* feed not explicitly set */
2012 entry_proto->resource_id(), 2011 entry_proto->resource_id(),
2013 FindEntryCallback(), // Not used. 2012 FileOperationCallback(), // Not used.
2014 base::Bind(&GDataFileSystem::OnRequestDirectoryRefresh, 2013 base::Bind(&GDataFileSystem::OnRequestDirectoryRefresh,
2015 ui_weak_ptr_)); 2014 ui_weak_ptr_));
2016 } 2015 }
2017 2016
2018 void GDataFileSystem::OnRequestDirectoryRefresh( 2017 void GDataFileSystem::OnRequestDirectoryRefresh(
2019 GetDocumentsParams* params, 2018 GetDocumentsParams* params,
2020 GDataFileError error) { 2019 GDataFileError error) {
2021 DCHECK(params); 2020 DCHECK(params);
2022 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2021 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2023 2022
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 initial_origin, 2451 initial_origin,
2453 0, 0, // We don't use change stamps when fetching search 2452 0, 0, // We don't use change stamps when fetching search
2454 // data; we always fetch the whole result feed. 2453 // data; we always fetch the whole result feed.
2455 false, // Stop fetching search results after first feed 2454 false, // Stop fetching search results after first feed
2456 // chunk to avoid displaying huge number of search 2455 // chunk to avoid displaying huge number of search
2457 // results (especially since we don't cache them). 2456 // results (especially since we don't cache them).
2458 FilePath(), // Not used. 2457 FilePath(), // Not used.
2459 search_query, 2458 search_query,
2460 next_feed, 2459 next_feed,
2461 std::string(), // No directory resource ID. 2460 std::string(), // No directory resource ID.
2462 FindEntryCallback(), // Not used. 2461 FileOperationCallback(), // Not used.
2463 base::Bind(&GDataFileSystem::OnSearch, ui_weak_ptr_, callback)); 2462 base::Bind(&GDataFileSystem::OnSearch, ui_weak_ptr_, callback));
2464 } 2463 }
2465 2464
2466 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) { 2465 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) {
2467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2466 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2468 2467
2469 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 2468 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
2470 OnDirectoryChanged(directory_path)); 2469 OnDirectoryChanged(directory_path));
2471 } 2470 }
2472 2471
(...skipping 11 matching lines...) Expand all
2484 OnFeedFromServerLoaded()); 2483 OnFeedFromServerLoaded());
2485 } 2484 }
2486 2485
2487 void GDataFileSystem::LoadRootFeedFromCacheForTesting() { 2486 void GDataFileSystem::LoadRootFeedFromCacheForTesting() {
2488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2489 2488
2490 feed_loader_->LoadFromCache( 2489 feed_loader_->LoadFromCache(
2491 false, // should_load_from_server. 2490 false, // should_load_from_server.
2492 // search_path doesn't matter if FindEntryCallback parameter is null . 2491 // search_path doesn't matter if FindEntryCallback parameter is null .
2493 FilePath(), 2492 FilePath(),
2494 FindEntryCallback()); 2493 FileOperationCallback());
2495 } 2494 }
2496 2495
2497 GDataFileError GDataFileSystem::UpdateFromFeedForTesting( 2496 GDataFileError GDataFileSystem::UpdateFromFeedForTesting(
2498 const std::vector<DocumentFeed*>& feed_list, 2497 const std::vector<DocumentFeed*>& feed_list,
2499 int64 start_changestamp, 2498 int64 start_changestamp,
2500 int64 root_feed_changestamp) { 2499 int64 root_feed_changestamp) {
2501 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2500 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2502 2501
2503 return feed_loader_->UpdateFromFeed(feed_list, 2502 return feed_loader_->UpdateFromFeed(feed_list,
2504 start_changestamp, 2503 start_changestamp,
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 2833
2835 void GDataFileSystem::NotifyFileSystemToBeUnmounted() { 2834 void GDataFileSystem::NotifyFileSystemToBeUnmounted() {
2836 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2835 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2837 2836
2838 DVLOG(1) << "File System is to be unmounted"; 2837 DVLOG(1) << "File System is to be unmounted";
2839 // Notify the observers that the file system is being unmounted. 2838 // Notify the observers that the file system is being unmounted.
2840 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 2839 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
2841 OnFileSystemBeingUnmounted()); 2840 OnFileSystemBeingUnmounted());
2842 } 2841 }
2843 2842
2844 void GDataFileSystem::RunAndNotifyInitialLoadFinished( 2843 void GDataFileSystem::FindAndNotifyInitialLoadFinished(
2844 const FilePath& search_file_path,
2845 const FindEntryCallback& callback, 2845 const FindEntryCallback& callback,
2846 GDataFileError error, 2846 GDataFileError error) {
2847 GDataEntry* entry) {
2848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2847 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2849 DCHECK(!callback.is_null()); 2848 DCHECK(!callback.is_null());
2850 2849
2851 callback.Run(error, entry); 2850 // TODO(satorux): Remove this: crbug.com/141196.
2851 directory_service_->FindEntryByPathAndRunSync(search_file_path, callback);
achuithb 2012/08/14 23:57:36 Why not just fix this? It's easy, right?
satorux1 2012/08/15 00:03:26 I'll fix this in the next patch, which makes thing
2852 2852
2853 DVLOG(1) << "RunAndNotifyInitialLoadFinished"; 2853 DVLOG(1) << "RunAndNotifyInitialLoadFinished";
2854 2854
2855 // Notify the observers that root directory has been initialized. 2855 // Notify the observers that root directory has been initialized.
2856 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, 2856 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_,
2857 OnInitialLoadFinished()); 2857 OnInitialLoadFinished());
2858 } 2858 }
2859 2859
2860 GDataFileError GDataFileSystem::AddNewDirectory( 2860 GDataFileError GDataFileSystem::AddNewDirectory(
2861 const FilePath& directory_path, base::Value* entry_value) { 2861 const FilePath& directory_path, base::Value* entry_value) {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 return; 3406 return;
3407 } 3407 }
3408 3408
3409 PlatformFileInfoProto entry_file_info; 3409 PlatformFileInfoProto entry_file_info;
3410 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3410 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3411 *entry_proto->mutable_file_info() = entry_file_info; 3411 *entry_proto->mutable_file_info() = entry_file_info;
3412 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3412 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3413 } 3413 }
3414 3414
3415 } // namespace gdata 3415 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698