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

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: 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) {
Ben Chan 2012/04/30 22:52:48 DCHECK(property_dict); DCHECK(file_proto.get());
satorux1 2012/04/30 23:04:36 Added the former. Didn't add the latter as it's po
1604 gdata::GDataEntry* entry) {
1605 if (error != base::PLATFORM_FILE_OK) { 1605 if (error != base::PLATFORM_FILE_OK) {
1606 property_dict->SetInteger("errorCode", error); 1606 property_dict->SetInteger("errorCode", error);
Ben Chan 2012/04/30 22:52:48 I believe the only semantics change is that this f
satorux1 2012/04/30 23:04:36 You are right. Before this patch, directory wasn't
1607 CompleteGetFileProperties(); 1607 CompleteGetFileProperties();
1608 return; 1608 return;
1609 } 1609 }
1610 1610
1611 gdata::GDataFile* file = entry->AsGDataFile(); 1611 property_dict->SetString("thumbnailUrl", file_proto->thumbnail_url());
1612 if (!file) { 1612 if (!file_proto->alternate_url().empty())
1613 LOG(WARNING) << "Reading properties of a non-file at " 1613 property_dict->SetString("editUrl", file_proto->alternate_url());
1614 << file_path.value(); 1614
1615 CompleteGetFileProperties(); 1615 if (!file_proto->gdata_entry().content_url().empty()) {
1616 return; 1616 property_dict->SetString("contentUrl",
1617 file_proto->gdata_entry().content_url());
1617 } 1618 }
1618 1619
1619 property_dict->SetString("thumbnailUrl", file->thumbnail_url().spec()); 1620 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 1621
1628 gdata::GDataSystemService* system_service = 1622 gdata::GDataSystemService* system_service =
1629 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 1623 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1630 system_service->file_system()->GetCacheState( 1624 system_service->file_system()->GetCacheState(
1631 file->resource_id(), 1625 file_proto->gdata_entry().resource_id(),
1632 file->file_md5(), 1626 file_proto->file_md5(),
1633 base::Bind( 1627 base::Bind(
1634 &GetGDataFilePropertiesFunction::CacheStateReceived, 1628 &GetGDataFilePropertiesFunction::CacheStateReceived,
1635 this, property_dict)); 1629 this, property_dict));
1636 } 1630 }
1637 1631
1638 void GetGDataFilePropertiesFunction::CacheStateReceived( 1632 void GetGDataFilePropertiesFunction::CacheStateReceived(
1639 base::DictionaryValue* property_dict, 1633 base::DictionaryValue* property_dict,
1640 base::PlatformFileError error, 1634 base::PlatformFileError error,
1641 int cache_state) { 1635 int cache_state) {
1642 property_dict->SetBoolean( 1636 property_dict->SetBoolean(
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 if (value->GetBoolean("cellularDisabled", &tmp)) { 2004 if (value->GetBoolean("cellularDisabled", &tmp)) {
2011 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); 2005 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp);
2012 } 2006 }
2013 2007
2014 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { 2008 if (value->GetBoolean("hostedFilesDisabled", &tmp)) {
2015 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); 2009 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp);
2016 } 2010 }
2017 2011
2018 return true; 2012 return true;
2019 } 2013 }
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