OLD | NEW |
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 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 GDataFileError error, | 2019 GDataFileError error, |
2020 scoped_ptr<GDataEntryProto> entry_proto) { | 2020 scoped_ptr<GDataEntryProto> entry_proto) { |
2021 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2021 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2022 | 2022 |
2023 if (error != GDATA_FILE_OK || | 2023 if (error != GDATA_FILE_OK || |
2024 !entry_proto->file_info().is_directory()) { | 2024 !entry_proto->file_info().is_directory()) { |
2025 LOG(ERROR) << "Directory entry not found: " << file_path.value(); | 2025 LOG(ERROR) << "Directory entry not found: " << file_path.value(); |
2026 return; | 2026 return; |
2027 } | 2027 } |
2028 | 2028 |
2029 feed_loader_->LoadFromServer( | 2029 feed_loader_->LoadDirectoryFromServer( |
2030 directory_service_->origin(), | 2030 directory_service_->origin(), |
2031 0, // start_changestamp - Not a delta feed. | 2031 entry_proto->resource_id(), |
2032 0, // root_feed_changestamp - Not used. | |
2033 true, // multiple feeds | |
2034 std::string(), // No search query | |
2035 GURL(), // feed_to_load - Feed not explicitly set | |
2036 entry_proto->resource_id(), // Load the feed for this directory. | |
2037 FileOperationCallback(), // load_finished_callback. | |
2038 base::Bind(&GDataFileSystem::OnRequestDirectoryRefresh, | 2032 base::Bind(&GDataFileSystem::OnRequestDirectoryRefresh, |
2039 ui_weak_ptr_, | 2033 ui_weak_ptr_, |
2040 file_path)); | 2034 file_path)); |
2041 } | 2035 } |
2042 | 2036 |
2043 void GDataFileSystem::OnRequestDirectoryRefresh( | 2037 void GDataFileSystem::OnRequestDirectoryRefresh( |
2044 const FilePath& directory_path, | 2038 const FilePath& directory_path, |
2045 GetDocumentsParams* params, | 2039 GetDocumentsParams* params, |
2046 GDataFileError error) { | 2040 GDataFileError error) { |
2047 DCHECK(params); | 2041 DCHECK(params); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 search_query, | 2422 search_query, |
2429 next_feed, | 2423 next_feed, |
2430 CreateRelayCallback(callback))); | 2424 CreateRelayCallback(callback))); |
2431 } | 2425 } |
2432 | 2426 |
2433 void GDataFileSystem::SearchAsyncOnUIThread( | 2427 void GDataFileSystem::SearchAsyncOnUIThread( |
2434 const std::string& search_query, | 2428 const std::string& search_query, |
2435 const GURL& next_feed, | 2429 const GURL& next_feed, |
2436 const SearchCallback& callback) { | 2430 const SearchCallback& callback) { |
2437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2431 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2438 scoped_ptr<std::vector<DocumentFeed*> > feed_list( | |
2439 new std::vector<DocumentFeed*>); | |
2440 | 2432 |
2441 ContentOrigin initial_origin = directory_service_->origin(); | 2433 feed_loader_->SearchFromServer( |
2442 feed_loader_->LoadFromServer( | 2434 directory_service_->origin(), |
2443 initial_origin, | |
2444 0, 0, // We don't use change stamps when fetching search | |
2445 // data; we always fetch the whole result feed. | |
2446 false, // Stop fetching search results after first feed | |
2447 // chunk to avoid displaying huge number of search | |
2448 // results (especially since we don't cache them). | |
2449 search_query, | 2435 search_query, |
2450 next_feed, | 2436 next_feed, |
2451 std::string(), // No directory resource ID. | |
2452 FileOperationCallback(), // Not used. | |
2453 base::Bind(&GDataFileSystem::OnSearch, ui_weak_ptr_, callback)); | 2437 base::Bind(&GDataFileSystem::OnSearch, ui_weak_ptr_, callback)); |
2454 } | 2438 } |
2455 | 2439 |
2456 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) { | 2440 void GDataFileSystem::OnDirectoryChanged(const FilePath& directory_path) { |
2457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2458 | 2442 |
2459 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, | 2443 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, |
2460 OnDirectoryChanged(directory_path)); | 2444 OnDirectoryChanged(directory_path)); |
2461 } | 2445 } |
2462 | 2446 |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3455 return; | 3439 return; |
3456 } | 3440 } |
3457 | 3441 |
3458 PlatformFileInfoProto entry_file_info; | 3442 PlatformFileInfoProto entry_file_info; |
3459 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3443 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
3460 *entry_proto->mutable_file_info() = entry_file_info; | 3444 *entry_proto->mutable_file_info() = entry_file_info; |
3461 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3445 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
3462 } | 3446 } |
3463 | 3447 |
3464 } // namespace gdata | 3448 } // namespace gdata |
OLD | NEW |