diff options
author | fukino@chromium.org <fukino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-16 06:19:16 +0000 |
---|---|---|
committer | fukino@chromium.org <fukino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-16 06:19:16 +0000 |
commit | 0f7c44ec45c2223c73653d694b89cd5b54b486da (patch) | |
tree | ed5c1ee6443db2f63c6da45ed57194fa4187232a /chrome/browser/drive | |
parent | 3f33ec20e933e5fa350ed9b5e9f7aa4e6f233286 (diff) | |
download | chromium_src-0f7c44ec45c2223c73653d694b89cd5b54b486da.zip chromium_src-0f7c44ec45c2223c73653d694b89cd5b54b486da.tar.gz chromium_src-0f7c44ec45c2223c73653d694b89cd5b54b486da.tar.bz2 |
Remove unused parsers and URL generators for WAPI.
Remove unused parsers, which are AccountMetadata, AppIcon, and InstalledApp.
ResourceEntry and ResourceList are in use, and other surviving parsers are referenced from ResourceEntry or ResourceList.
Remove unused URL generator for WAPI along with parsers.
BUG=353554
TEST=run unit_tests
Review URL: https://codereview.chromium.org/236743002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/drive')
-rw-r--r-- | chrome/browser/drive/drive_api_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/drive/drive_api_util.cc | 119 | ||||
-rw-r--r-- | chrome/browser/drive/drive_api_util.h | 16 | ||||
-rw-r--r-- | chrome/browser/drive/drive_api_util_unittest.cc | 115 | ||||
-rw-r--r-- | chrome/browser/drive/drive_app_registry.cc | 12 | ||||
-rw-r--r-- | chrome/browser/drive/drive_app_registry.h | 13 | ||||
-rw-r--r-- | chrome/browser/drive/drive_app_registry_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/drive/fake_drive_service.cc | 1 |
8 files changed, 16 insertions, 266 deletions
diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc index dd464d5..017dc1a 100644 --- a/chrome/browser/drive/drive_api_service.cc +++ b/chrome/browser/drive/drive_api_service.cc @@ -292,7 +292,7 @@ DriveAPIService::DriveAPIService( url_request_context_getter_(url_request_context_getter), blocking_task_runner_(blocking_task_runner), url_generator_(base_url, base_download_url), - wapi_url_generator_(wapi_base_url, base_download_url), + wapi_url_generator_(wapi_base_url), custom_user_agent_(custom_user_agent) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); } diff --git a/chrome/browser/drive/drive_api_util.cc b/chrome/browser/drive/drive_api_util.cc index 485c4f6..5c025ca 100644 --- a/chrome/browser/drive/drive_api_util.cc +++ b/chrome/browser/drive/drive_api_util.cc @@ -55,91 +55,6 @@ std::string GetMimeTypeFromEntryKind(google_apis::DriveEntryKind kind) { } } -ScopedVector<std::string> CopyScopedVectorString( - const ScopedVector<std::string>& source) { - ScopedVector<std::string> result; - result.reserve(source.size()); - for (size_t i = 0; i < source.size(); ++i) - result.push_back(new std::string(*source[i])); - - return result.Pass(); -} - -// Converts AppIcon (of GData WAPI) to DriveAppIcon. -scoped_ptr<google_apis::DriveAppIcon> -ConvertAppIconToDriveAppIcon(const google_apis::AppIcon& app_icon) { - scoped_ptr<google_apis::DriveAppIcon> resource( - new google_apis::DriveAppIcon); - switch (app_icon.category()) { - case google_apis::AppIcon::ICON_UNKNOWN: - resource->set_category(google_apis::DriveAppIcon::UNKNOWN); - break; - case google_apis::AppIcon::ICON_DOCUMENT: - resource->set_category(google_apis::DriveAppIcon::DOCUMENT); - break; - case google_apis::AppIcon::ICON_APPLICATION: - resource->set_category(google_apis::DriveAppIcon::APPLICATION); - break; - case google_apis::AppIcon::ICON_SHARED_DOCUMENT: - resource->set_category(google_apis::DriveAppIcon::SHARED_DOCUMENT); - break; - default: - NOTREACHED(); - } - - resource->set_icon_side_length(app_icon.icon_side_length()); - resource->set_icon_url(app_icon.GetIconURL()); - return resource.Pass(); -} - -// Converts InstalledApp to AppResource. -scoped_ptr<google_apis::AppResource> -ConvertInstalledAppToAppResource( - const google_apis::InstalledApp& installed_app) { - scoped_ptr<google_apis::AppResource> resource(new google_apis::AppResource); - resource->set_application_id(installed_app.app_id()); - resource->set_name(installed_app.app_name()); - resource->set_object_type(installed_app.object_type()); - resource->set_supports_create(installed_app.supports_create()); - - { - ScopedVector<std::string> primary_mimetypes( - CopyScopedVectorString(installed_app.primary_mimetypes())); - resource->set_primary_mimetypes(primary_mimetypes.Pass()); - } - { - ScopedVector<std::string> secondary_mimetypes( - CopyScopedVectorString(installed_app.secondary_mimetypes())); - resource->set_secondary_mimetypes(secondary_mimetypes.Pass()); - } - { - ScopedVector<std::string> primary_file_extensions( - CopyScopedVectorString(installed_app.primary_extensions())); - resource->set_primary_file_extensions(primary_file_extensions.Pass()); - } - { - ScopedVector<std::string> secondary_file_extensions( - CopyScopedVectorString(installed_app.secondary_extensions())); - resource->set_secondary_file_extensions(secondary_file_extensions.Pass()); - } - - { - const ScopedVector<google_apis::AppIcon>& app_icons = - installed_app.app_icons(); - ScopedVector<google_apis::DriveAppIcon> icons; - icons.reserve(app_icons.size()); - for (size_t i = 0; i < app_icons.size(); ++i) { - icons.push_back(ConvertAppIconToDriveAppIcon(*app_icons[i]).release()); - } - resource->set_icons(icons.Pass()); - } - - // supports_import, installed and authorized are not supported in - // InstalledApp. - - return resource.Pass(); -} - // Returns the argument string. std::string Identity(const std::string& resource_id) { return resource_id; } @@ -270,40 +185,6 @@ void ParseShareUrlAndRun(const google_apis::GetShareUrlCallback& callback, callback.Run(error, share_link ? share_link->href() : GURL()); } -scoped_ptr<google_apis::AboutResource> -ConvertAccountMetadataToAboutResource( - const google_apis::AccountMetadata& account_metadata, - const std::string& root_resource_id) { - scoped_ptr<google_apis::AboutResource> resource( - new google_apis::AboutResource); - resource->set_largest_change_id(account_metadata.largest_changestamp()); - resource->set_quota_bytes_total(account_metadata.quota_bytes_total()); - resource->set_quota_bytes_used(account_metadata.quota_bytes_used()); - resource->set_root_folder_id(root_resource_id); - return resource.Pass(); -} - -scoped_ptr<google_apis::AppList> -ConvertAccountMetadataToAppList( - const google_apis::AccountMetadata& account_metadata) { - scoped_ptr<google_apis::AppList> resource(new google_apis::AppList); - - const ScopedVector<google_apis::InstalledApp>& installed_apps = - account_metadata.installed_apps(); - ScopedVector<google_apis::AppResource> app_resources; - app_resources.reserve(installed_apps.size()); - for (size_t i = 0; i < installed_apps.size(); ++i) { - app_resources.push_back( - ConvertInstalledAppToAppResource(*installed_apps[i]).release()); - } - resource->set_items(app_resources.Pass()); - - // etag is not supported in AccountMetadata. - - return resource.Pass(); -} - - scoped_ptr<google_apis::FileResource> ConvertResourceEntryToFileResource( const google_apis::ResourceEntry& entry) { scoped_ptr<google_apis::FileResource> file(new google_apis::FileResource); diff --git a/chrome/browser/drive/drive_api_util.h b/chrome/browser/drive/drive_api_util.h index 324a46c..80122a4 100644 --- a/chrome/browser/drive/drive_api_util.h +++ b/chrome/browser/drive/drive_api_util.h @@ -21,8 +21,6 @@ class Value; } // namespace base namespace google_apis { -class AccountMetadata; -class AppIcon; class AppList; class AppResource; class ChangeList; @@ -30,7 +28,6 @@ class ChangeResource; class DriveAppIcon; class FileList; class FileResource; -class InstalledApp; class ResourceEntry; class ResourceList; } // namespace google_apis @@ -80,19 +77,6 @@ void ParseShareUrlAndRun(const google_apis::GetShareUrlCallback& callback, google_apis::GDataErrorCode error, scoped_ptr<base::Value> value); -// Converts AccountMetadata to AboutResource. -// Here, |root_resource_id| is also needed, as it is contained by AboutResource -// but not by AccountMetadata. -scoped_ptr<google_apis::AboutResource> -ConvertAccountMetadataToAboutResource( - const google_apis::AccountMetadata& account_metadata, - const std::string& root_resource_id); - -// Converts AccountMetadata to AppList. -scoped_ptr<google_apis::AppList> -ConvertAccountMetadataToAppList( - const google_apis::AccountMetadata& account_metadata); - // Converts ResourceEntry to FileResource. scoped_ptr<google_apis::FileResource> ConvertResourceEntryToFileResource(const google_apis::ResourceEntry& entry); diff --git a/chrome/browser/drive/drive_api_util_unittest.cc b/chrome/browser/drive/drive_api_util_unittest.cc index af405f3..7a72db7 100644 --- a/chrome/browser/drive/drive_api_util_unittest.cc +++ b/chrome/browser/drive/drive_api_util_unittest.cc @@ -79,121 +79,6 @@ TEST(FileSystemUtilTest, CanonicalizeResourceId) { EXPECT_EQ(resource_id, CanonicalizeResourceId("externalapp:" + resource_id)); } -TEST(FileSystemUtilTest, ConvertAccountMetadataToAboutResource) { - google_apis::AccountMetadata account_metadata; - // Set up AccountMetadata instance. - { - account_metadata.set_quota_bytes_total(10000); - account_metadata.set_quota_bytes_used(1000); - account_metadata.set_largest_changestamp(100); - } - - scoped_ptr<google_apis::AboutResource> about_resource( - ConvertAccountMetadataToAboutResource( - account_metadata, "dummy_root_id")); - - EXPECT_EQ(10000, about_resource->quota_bytes_total()); - EXPECT_EQ(1000, about_resource->quota_bytes_used()); - EXPECT_EQ(100, about_resource->largest_change_id()); - EXPECT_EQ("dummy_root_id", about_resource->root_folder_id()); -} - -TEST(FileSystemUtilTest, ConvertAccountMetadataToAppList) { - google_apis::AccountMetadata account_metadata; - // Set up AccountMetadata instance. - { - ScopedVector<google_apis::InstalledApp> installed_apps; - scoped_ptr<google_apis::InstalledApp> installed_app( - new google_apis::InstalledApp); - installed_app->set_app_id("app_id"); - installed_app->set_app_name("name"); - installed_app->set_object_type("object_type"); - installed_app->set_supports_create(true); - - { - ScopedVector<google_apis::Link> links; - scoped_ptr<google_apis::Link> link(new google_apis::Link); - link->set_type(google_apis::Link::LINK_PRODUCT); - link->set_href(GURL("http://product/url")); - links.push_back(link.release()); - installed_app->set_links(links.Pass()); - } - { - ScopedVector<std::string> primary_mimetypes; - primary_mimetypes.push_back(new std::string("primary_mimetype")); - installed_app->set_primary_mimetypes(primary_mimetypes.Pass()); - } - { - ScopedVector<std::string> secondary_mimetypes; - secondary_mimetypes.push_back(new std::string("secondary_mimetype")); - installed_app->set_secondary_mimetypes(secondary_mimetypes.Pass()); - } - { - ScopedVector<std::string> primary_extensions; - primary_extensions.push_back(new std::string("primary_extension")); - installed_app->set_primary_extensions(primary_extensions.Pass()); - } - { - ScopedVector<std::string> secondary_extensions; - secondary_extensions.push_back(new std::string("secondary_extension")); - installed_app->set_secondary_extensions(secondary_extensions.Pass()); - } - { - ScopedVector<google_apis::AppIcon> app_icons; - scoped_ptr<google_apis::AppIcon> app_icon(new google_apis::AppIcon); - app_icon->set_category(google_apis::AppIcon::ICON_DOCUMENT); - app_icon->set_icon_side_length(10); - { - ScopedVector<google_apis::Link> links; - scoped_ptr<google_apis::Link> link(new google_apis::Link); - link->set_type(google_apis::Link::LINK_ICON); - link->set_href(GURL("http://icon/url")); - links.push_back(link.release()); - app_icon->set_links(links.Pass()); - } - app_icons.push_back(app_icon.release()); - installed_app->set_app_icons(app_icons.Pass()); - } - - installed_apps.push_back(installed_app.release()); - account_metadata.set_installed_apps(installed_apps.Pass()); - } - - scoped_ptr<google_apis::AppList> app_list( - ConvertAccountMetadataToAppList(account_metadata)); - const ScopedVector<google_apis::AppResource>& items = app_list->items(); - ASSERT_EQ(1U, items.size()); - - const google_apis::AppResource& app_resource = *items[0]; - EXPECT_EQ("app_id", app_resource.application_id()); - EXPECT_EQ("name", app_resource.name()); - EXPECT_EQ("object_type", app_resource.object_type()); - EXPECT_TRUE(app_resource.supports_create()); - const ScopedVector<std::string>& primary_mimetypes = - app_resource.primary_mimetypes(); - ASSERT_EQ(1U, primary_mimetypes.size()); - EXPECT_EQ("primary_mimetype", *primary_mimetypes[0]); - const ScopedVector<std::string>& secondary_mimetypes = - app_resource.secondary_mimetypes(); - ASSERT_EQ(1U, secondary_mimetypes.size()); - EXPECT_EQ("secondary_mimetype", *secondary_mimetypes[0]); - const ScopedVector<std::string>& primary_file_extensions = - app_resource.primary_file_extensions(); - ASSERT_EQ(1U, primary_file_extensions.size()); - EXPECT_EQ("primary_extension", *primary_file_extensions[0]); - const ScopedVector<std::string>& secondary_file_extensions = - app_resource.secondary_file_extensions(); - ASSERT_EQ(1U, secondary_file_extensions.size()); - EXPECT_EQ("secondary_extension", *secondary_file_extensions[0]); - - const ScopedVector<google_apis::DriveAppIcon>& icons = app_resource.icons(); - ASSERT_EQ(1U, icons.size()); - const google_apis::DriveAppIcon& icon = *icons[0]; - EXPECT_EQ(google_apis::DriveAppIcon::DOCUMENT, icon.category()); - EXPECT_EQ(10, icon.icon_side_length()); - EXPECT_EQ("http://icon/url", icon.icon_url().spec()); -} - TEST(FileSystemUtilTest, ConvertFileResourceToResource_Parents) { google_apis::FileResource file_resource; diff --git a/chrome/browser/drive/drive_app_registry.cc b/chrome/browser/drive/drive_app_registry.cc index 43072bb..1fc08b2 100644 --- a/chrome/browser/drive/drive_app_registry.cc +++ b/chrome/browser/drive/drive_app_registry.cc @@ -58,8 +58,8 @@ DriveAppInfo::DriveAppInfo() { DriveAppInfo::DriveAppInfo( const std::string& app_id, const std::string& product_id, - const google_apis::InstalledApp::IconList& app_icons, - const google_apis::InstalledApp::IconList& document_icons, + const IconList& app_icons, + const IconList& document_icons, const std::string& app_name, const GURL& create_url, bool is_removable) @@ -159,8 +159,8 @@ void DriveAppRegistry::UpdateFromAppList(const google_apis::AppList& app_list) { const google_apis::AppResource& app = *app_list.items()[i]; const std::string id = app.application_id(); - google_apis::InstalledApp::IconList app_icons; - google_apis::InstalledApp::IconList document_icons; + DriveAppInfo::IconList app_icons; + DriveAppInfo::IconList document_icons; for (size_t j = 0; j < app.icons().size(); ++j) { const google_apis::DriveAppIcon& icon = *app.icons()[j]; if (icon.icon_url().is_empty()) @@ -230,12 +230,12 @@ bool DriveAppRegistry::IsAppUninstallSupported() { namespace util { -GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, +GURL FindPreferredIcon(const DriveAppInfo::IconList& icons, int preferred_size) { if (icons.empty()) return GURL(); - google_apis::InstalledApp::IconList sorted_icons = icons; + DriveAppInfo::IconList sorted_icons = icons; std::sort(sorted_icons.rbegin(), sorted_icons.rend()); // Go forward while the size is larger or equal to preferred_size. diff --git a/chrome/browser/drive/drive_app_registry.h b/chrome/browser/drive/drive_app_registry.h index 7f8ee0c..0c5d7aa 100644 --- a/chrome/browser/drive/drive_app_registry.h +++ b/chrome/browser/drive/drive_app_registry.h @@ -15,7 +15,6 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "google_apis/drive/gdata_errorcode.h" -#include "google_apis/drive/gdata_wapi_parser.h" #include "url/gurl.h" namespace google_apis { @@ -31,11 +30,13 @@ class DriveServiceInterface; // https://chrome.google.com/webstore/category/collection/drive_apps for // Drive apps available on the webstore. struct DriveAppInfo { + typedef std::vector<std::pair<int, GURL> > IconList; + DriveAppInfo(); DriveAppInfo(const std::string& app_id, const std::string& product_id, - const google_apis::InstalledApp::IconList& app_icons, - const google_apis::InstalledApp::IconList& document_icons, + const IconList& app_icons, + const IconList& document_icons, const std::string& app_name, const GURL& create_url, bool is_removable); @@ -50,10 +51,10 @@ struct DriveAppInfo { std::string product_id; // Drive application icon URLs for this app, paired with their size (length of // a side in pixels). - google_apis::InstalledApp::IconList app_icons; + IconList app_icons; // Drive document icon URLs for this app, paired with their size (length of // a side in pixels). - google_apis::InstalledApp::IconList document_icons; + IconList document_icons; // App name. std::string app_name; // URL for opening a new file in the app. Empty if the app does not support @@ -145,7 +146,7 @@ const int kPreferredIconSize = 16; // smaller than the preferred size, we'll return the largest one available. // Icons do not have to be sorted by the icon size. If there are no icons in // the list, returns an empty URL. -GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, +GURL FindPreferredIcon(const DriveAppInfo::IconList& icons, int preferred_size); } // namespace util diff --git a/chrome/browser/drive/drive_app_registry_unittest.cc b/chrome/browser/drive/drive_app_registry_unittest.cc index 8e5262c..2604f2e 100644 --- a/chrome/browser/drive/drive_app_registry_unittest.cc +++ b/chrome/browser/drive/drive_app_registry_unittest.cc @@ -153,7 +153,7 @@ TEST_F(DriveAppRegistryTest, MultipleUpdate) { } TEST(DriveAppRegistryUtilTest, FindPreferredIcon_Empty) { - google_apis::InstalledApp::IconList icons; + DriveAppInfo::IconList icons; EXPECT_EQ("", util::FindPreferredIcon(icons, util::kPreferredIconSize).spec()); } @@ -164,7 +164,7 @@ TEST(DriveAppRegistryUtilTest, FindPreferredIcon_) { const char kBiggerIconUrl[] = "http://example.com/bigger.png"; const int kMediumSize = 16; - google_apis::InstalledApp::IconList icons; + DriveAppInfo::IconList icons; // The icons are not sorted by the size. icons.push_back(std::make_pair(kMediumSize, GURL(kMediumIconUrl))); diff --git a/chrome/browser/drive/fake_drive_service.cc b/chrome/browser/drive/fake_drive_service.cc index c2b9946..6404167 100644 --- a/chrome/browser/drive/fake_drive_service.cc +++ b/chrome/browser/drive/fake_drive_service.cc @@ -28,7 +28,6 @@ using content::BrowserThread; using google_apis::AboutResource; using google_apis::AboutResourceCallback; -using google_apis::AccountMetadata; using google_apis::AppList; using google_apis::AppListCallback; using google_apis::AuthStatusCallback; |