| 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_wapi_feed_loader.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // First fetch the latest changestamp to see if there were any new changes | 232 // First fetch the latest changestamp to see if there were any new changes |
| 233 // there at all. | 233 // there at all. |
| 234 if (gdata::util::IsDriveV2ApiEnabled()) { | 234 if (gdata::util::IsDriveV2ApiEnabled()) { |
| 235 documents_service_->GetAboutResource( | 235 documents_service_->GetAboutResource( |
| 236 base::Bind(&GDataWapiFeedLoader::OnGetAboutResource, | 236 base::Bind(&GDataWapiFeedLoader::OnGetAboutResource, |
| 237 weak_ptr_factory_.GetWeakPtr(), | 237 weak_ptr_factory_.GetWeakPtr(), |
| 238 initial_origin, | 238 initial_origin, |
| 239 local_changestamp, | 239 local_changestamp, |
| 240 search_file_path, | 240 search_file_path, |
| 241 callback)); | 241 callback)); |
| 242 // Drive v2 needs a separate application list fetch operation. |
| 243 // TODO(kochi): Application list rarely changes and do not necessarily |
| 244 // refresed as often as files. |
| 245 documents_service_->GetApplicationList( |
| 246 base::Bind(&GDataWapiFeedLoader::OnGetApplicationList, |
| 247 weak_ptr_factory_.GetWeakPtr())); |
| 242 return; | 248 return; |
| 243 } | 249 } |
| 244 | 250 |
| 245 documents_service_->GetAccountMetadata( | 251 documents_service_->GetAccountMetadata( |
| 246 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, | 252 base::Bind(&GDataWapiFeedLoader::OnGetAccountMetadata, |
| 247 weak_ptr_factory_.GetWeakPtr(), | 253 weak_ptr_factory_.GetWeakPtr(), |
| 248 initial_origin, | 254 initial_origin, |
| 249 local_changestamp, | 255 local_changestamp, |
| 250 search_file_path, | 256 search_file_path, |
| 251 callback)); | 257 callback)); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 true, /* should_fetch_multiple_feeds */ | 429 true, /* should_fetch_multiple_feeds */ |
| 424 search_file_path, | 430 search_file_path, |
| 425 std::string() /* no search query */, | 431 std::string() /* no search query */, |
| 426 GURL(), /* feed not explicitly set */ | 432 GURL(), /* feed not explicitly set */ |
| 427 std::string() /* no directory resource ID */, | 433 std::string() /* no directory resource ID */, |
| 428 callback, | 434 callback, |
| 429 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded, | 435 base::Bind(&GDataWapiFeedLoader::OnFeedFromServerLoaded, |
| 430 weak_ptr_factory_.GetWeakPtr())); | 436 weak_ptr_factory_.GetWeakPtr())); |
| 431 } | 437 } |
| 432 | 438 |
| 439 void GDataWapiFeedLoader::OnGetApplicationList( |
| 440 GDataErrorCode status, |
| 441 scoped_ptr<base::Value> json) { |
| 442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 443 |
| 444 GDataFileError error = util::GDataToGDataFileError(status); |
| 445 if (error != GDATA_FILE_OK) |
| 446 return; |
| 447 |
| 448 if (json.get()) { |
| 449 scoped_ptr<AppList> applist(AppList::CreateFrom(*json)); |
| 450 if (applist.get()) { |
| 451 VLOG(1) << "applist get success"; |
| 452 webapps_registry_->UpdateFromApplicationList(applist.get()); |
| 453 } |
| 454 } |
| 455 } |
| 456 |
| 433 // TODO(kochi): Fix too many parameters. http://crbug.com/141359 | 457 // TODO(kochi): Fix too many parameters. http://crbug.com/141359 |
| 434 void GDataWapiFeedLoader::LoadFromServer( | 458 void GDataWapiFeedLoader::LoadFromServer( |
| 435 ContentOrigin initial_origin, | 459 ContentOrigin initial_origin, |
| 436 int64 start_changestamp, | 460 int64 start_changestamp, |
| 437 int64 root_feed_changestamp, | 461 int64 root_feed_changestamp, |
| 438 bool should_fetch_multiple_feeds, | 462 bool should_fetch_multiple_feeds, |
| 439 const FilePath& search_file_path, | 463 const FilePath& search_file_path, |
| 440 const std::string& search_query, | 464 const std::string& search_query, |
| 441 const GURL& feed_to_load, | 465 const GURL& feed_to_load, |
| 442 const std::string& directory_resource_id, | 466 const std::string& directory_resource_id, |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 dir_iter != changed_dirs.end(); ++dir_iter) { | 830 dir_iter != changed_dirs.end(); ++dir_iter) { |
| 807 FOR_EACH_OBSERVER(Observer, observers_, | 831 FOR_EACH_OBSERVER(Observer, observers_, |
| 808 OnDirectoryChanged(*dir_iter)); | 832 OnDirectoryChanged(*dir_iter)); |
| 809 } | 833 } |
| 810 } | 834 } |
| 811 | 835 |
| 812 return error; | 836 return error; |
| 813 } | 837 } |
| 814 | 838 |
| 815 } // namespace gdata | 839 } // namespace gdata |
| OLD | NEW |