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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_api.cc

Issue 10271016: gdata: Remove use of FindEntryByPathAsync() from file_browser_private_api.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 7 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/extensions/file_browser_private_api.h ('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 (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/extensions/file_browser_private_api.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/chromeos/extensions/file_handler_util.h" 18 #include "chrome/browser/chromeos/extensions/file_handler_util.h"
19 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 19 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
20 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
20 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" 21 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h"
21 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" 22 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h"
22 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 23 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
23 #include "chrome/browser/chromeos/gdata/gdata_util.h" 24 #include "chrome/browser/chromeos/gdata/gdata_util.h"
24 #include "chrome/browser/extensions/extension_function_dispatcher.h" 25 #include "chrome/browser/extensions/extension_function_dispatcher.h"
25 #include "chrome/browser/extensions/extension_process_manager.h" 26 #include "chrome/browser/extensions/extension_process_manager.h"
26 #include "chrome/browser/extensions/extension_service.h" 27 #include "chrome/browser/extensions/extension_service.h"
27 #include "chrome/browser/extensions/extension_tab_util.h" 28 #include "chrome/browser/extensions/extension_tab_util.h"
28 #include "chrome/browser/extensions/process_map.h" 29 #include "chrome/browser/extensions/process_map.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 base::DictionaryValue* property_dict, 1582 base::DictionaryValue* property_dict,
1582 base::PlatformFileError error) { 1583 base::PlatformFileError error) {
1583 if (error != base::PLATFORM_FILE_OK) { 1584 if (error != base::PLATFORM_FILE_OK) {
1584 property_dict->SetInteger("errorCode", error); 1585 property_dict->SetInteger("errorCode", error);
1585 CompleteGetFileProperties(); 1586 CompleteGetFileProperties();
1586 return; 1587 return;
1587 } 1588 }
1588 1589
1589 gdata::GDataSystemService* system_service = 1590 gdata::GDataSystemService* system_service =
1590 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 1591 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1591 system_service->file_system()->FindEntryByPathAsync( 1592 system_service->file_system()->GetFileInfoByPathAsync(
1592 path, 1593 path,
1593 base::Bind(&GetGDataFilePropertiesFunction::OnFileProperties, 1594 base::Bind(&GetGDataFilePropertiesFunction::OnGetFileInfo,
1594 this, 1595 this,
1595 property_dict, 1596 property_dict,
1596 path)); 1597 path));
1597 } 1598 }
1598 1599
1599 void GetGDataFilePropertiesFunction::OnFileProperties( 1600 void GetGDataFilePropertiesFunction::OnGetFileInfo(
1600 base::DictionaryValue* property_dict, 1601 base::DictionaryValue* property_dict,
1601 const FilePath& file_path, 1602 const FilePath& file_path,
1602 base::PlatformFileError error, 1603 base::PlatformFileError error,
1603 const FilePath& /* directory_path */, 1604 scoped_ptr<gdata::GDataFileProto> file_proto) {
1604 gdata::GDataEntry* entry) { 1605 DCHECK(property_dict);
1606
1605 if (error != base::PLATFORM_FILE_OK) { 1607 if (error != base::PLATFORM_FILE_OK) {
1606 property_dict->SetInteger("errorCode", error); 1608 property_dict->SetInteger("errorCode", error);
1607 CompleteGetFileProperties(); 1609 CompleteGetFileProperties();
1608 return; 1610 return;
1609 } 1611 }
1610 1612
1611 gdata::GDataFile* file = entry->AsGDataFile(); 1613 property_dict->SetString("thumbnailUrl", file_proto->thumbnail_url());
Ben Chan 2012/05/01 05:09:43 perhaps DCHECK(file_proto.get()) here instead?
satorux1 2012/05/01 05:21:30 Done.
1612 if (!file) { 1614 if (!file_proto->alternate_url().empty())
1613 LOG(WARNING) << "Reading properties of a non-file at " 1615 property_dict->SetString("editUrl", file_proto->alternate_url());
1614 << file_path.value(); 1616
1615 CompleteGetFileProperties(); 1617 if (!file_proto->gdata_entry().content_url().empty()) {
1616 return; 1618 property_dict->SetString("contentUrl",
1619 file_proto->gdata_entry().content_url());
1617 } 1620 }
1618 1621
1619 property_dict->SetString("thumbnailUrl", file->thumbnail_url().spec()); 1622 property_dict->SetBoolean("isHosted", file_proto->is_hosted_document());
1620 if (!file->alternate_url().is_empty())
1621 property_dict->SetString("editUrl", file->alternate_url().spec());
1622
1623 if (!file->content_url().is_empty())
1624 property_dict->SetString("contentUrl", file->content_url().spec());
1625
1626 property_dict->SetBoolean("isHosted", file->is_hosted_document());
1627 1623
1628 gdata::GDataSystemService* system_service = 1624 gdata::GDataSystemService* system_service =
1629 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 1625 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1630 system_service->file_system()->GetCacheState( 1626 system_service->file_system()->GetCacheState(
1631 file->resource_id(), 1627 file_proto->gdata_entry().resource_id(),
1632 file->file_md5(), 1628 file_proto->file_md5(),
1633 base::Bind( 1629 base::Bind(
1634 &GetGDataFilePropertiesFunction::CacheStateReceived, 1630 &GetGDataFilePropertiesFunction::CacheStateReceived,
1635 this, property_dict)); 1631 this, property_dict));
1636 } 1632 }
1637 1633
1638 void GetGDataFilePropertiesFunction::CacheStateReceived( 1634 void GetGDataFilePropertiesFunction::CacheStateReceived(
1639 base::DictionaryValue* property_dict, 1635 base::DictionaryValue* property_dict,
1640 base::PlatformFileError error, 1636 base::PlatformFileError error,
1641 int cache_state) { 1637 int cache_state) {
1642 property_dict->SetBoolean( 1638 property_dict->SetBoolean(
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 if (value->GetBoolean("cellularDisabled", &tmp)) { 2006 if (value->GetBoolean("cellularDisabled", &tmp)) {
2011 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); 2007 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp);
2012 } 2008 }
2013 2009
2014 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { 2010 if (value->GetBoolean("hostedFilesDisabled", &tmp)) {
2015 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); 2011 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp);
2016 } 2012 }
2017 2013
2018 return true; 2014 return true;
2019 } 2015 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698