Skip to content

Commit

Permalink
Remove WAPI-related code, except the type definition of ResourceEntry.
Browse files Browse the repository at this point in the history
To remove ResourceEntry completely, tests for syncFileSystem need to be modified.
I'll do it by a separate CL.

BUG=357038
TBR=rogerta@chromium.org
TBRing for removal of unused files from *.gyp and *.gn under google_api
TEST=build all targets

Review URL: https://codereview.chromium.org/861133002

Cr-Commit-Position: refs/heads/master@{#313202}
  • Loading branch information
fukino authored and Commit bot committed Jan 27, 2015
1 parent 5393fb5 commit 99daa8e
Show file tree
Hide file tree
Showing 27 changed files with 5 additions and 2,077 deletions.
1 change: 0 additions & 1 deletion chrome/browser/apps/drive/drive_service_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ void DriveServiceBridgeImpl::Initialize() {
drive_task_runner.get(),
GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction),
GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction),
GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction),
std::string() /* custom_user_agent */));
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile_);
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/chromeos/drive/change_list_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Time;

namespace google_apis {
class AboutResource;
class ResourceList;
} // namespace google_apis

namespace drive {
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/chromeos/drive/drive_integration_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "content/public/browser/notification_service.h"
#include "content/public/common/user_agent.h"
#include "google_apis/drive/auth_service.h"
#include "google_apis/drive/gdata_wapi_url_generator.h"
#include "storage/browser/fileapi/external_mount_points.h"
#include "ui/base/l10n/l10n_util.h"

Expand Down Expand Up @@ -240,7 +239,6 @@ DriveIntegrationService::DriveIntegrationService(
blocking_task_runner_.get(),
GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction),
GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction),
GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction),
GetDriveUserAgent()));
}
scheduler_.reset(new JobScheduler(
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/drive/drive_api_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "google_apis/drive/auth_service.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/drive_api_requests.h"
#include "google_apis/drive/gdata_errorcode.h"
#include "google_apis/drive/request_sender.h"
#include "google_apis/google_api_keys.h"
#include "net/url_request/url_request_context_getter.h"
Expand Down Expand Up @@ -166,13 +165,11 @@ DriveAPIService::DriveAPIService(
base::SequencedTaskRunner* blocking_task_runner,
const GURL& base_url,
const GURL& base_download_url,
const GURL& wapi_base_url,
const std::string& custom_user_agent)
: oauth2_token_service_(oauth2_token_service),
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),
custom_user_agent_(custom_user_agent) {
}

Expand Down
6 changes: 0 additions & 6 deletions chrome/browser/drive/drive_api_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "google_apis/drive/auth_service_interface.h"
#include "google_apis/drive/auth_service_observer.h"
#include "google_apis/drive/drive_api_url_generator.h"
#include "google_apis/drive/gdata_wapi_url_generator.h"

class GURL;
class OAuth2TokenService;
Expand Down Expand Up @@ -47,9 +46,6 @@ class DriveAPIService : public DriveServiceInterface,
// |base_url| is used to generate URLs for communication with the drive API.
// |base_download_url| is used to generate URLs for downloading file from the
// drive API.
// |wapi_base_url| is used to generate URLs for shared_url. Unfortunately,
// the share_url is not yet supported on Drive API v2, so as a fallback,
// we use GData WAPI.
// |custom_user_agent| will be used for the User-Agent header in HTTP
// requests issues through the service if the value is not empty.
DriveAPIService(
Expand All @@ -58,7 +54,6 @@ class DriveAPIService : public DriveServiceInterface,
base::SequencedTaskRunner* blocking_task_runner,
const GURL& base_url,
const GURL& base_download_url,
const GURL& wapi_base_url,
const std::string& custom_user_agent);
~DriveAPIService() override;

Expand Down Expand Up @@ -214,7 +209,6 @@ class DriveAPIService : public DriveServiceInterface,
scoped_ptr<google_apis::RequestSender> sender_;
ObserverList<DriveServiceObserver> observers_;
google_apis::DriveApiUrlGenerator url_generator_;
google_apis::GDataWapiUrlGenerator wapi_url_generator_;
const std::string custom_user_agent_;

DISALLOW_COPY_AND_ASSIGN(DriveAPIService);
Expand Down
123 changes: 0 additions & 123 deletions chrome/browser/drive/drive_api_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ std::string TranslateQuery(const std::string& original_query) {
return result;
}

std::string ExtractResourceIdFromUrl(const GURL& url) {
return net::UnescapeURLComponent(url.ExtractFileName(),
net::UnescapeRule::URL_SPECIAL_CHARS);
}

std::string CanonicalizeResourceId(const std::string& resource_id) {
// If resource ID is in the old WAPI format starting with a prefix like
// "document:", strip it and return the remaining part.
Expand All @@ -143,140 +138,22 @@ ConvertFileResourceToResourceEntry(

// ResourceEntry
entry->set_resource_id(file_resource.file_id());
entry->set_id(file_resource.file_id());
if (file_resource.IsDirectory())
entry->set_kind(google_apis::ResourceEntry::ENTRY_KIND_FOLDER);
else if (file_resource.IsHostedDocument())
entry->set_kind(google_apis::ResourceEntry::ENTRY_KIND_UNKNOWN);
else
entry->set_kind(google_apis::ResourceEntry::ENTRY_KIND_FILE);
entry->set_title(file_resource.title());
entry->set_published_time(file_resource.created_date());

std::vector<std::string> labels;
if (!file_resource.shared_with_me_date().is_null())
labels.push_back("shared-with-me");
if (file_resource.shared())
labels.push_back("shared");
entry->set_labels(labels);

// This should be the url to download the file_resource.
{
google_apis::Content content;
content.set_mime_type(file_resource.mime_type());
entry->set_content(content);
}
// TODO(kochi): entry->resource_links_

// For file entries
entry->set_filename(file_resource.title());
entry->set_suggested_filename(file_resource.title());
entry->set_file_md5(file_resource.md5_checksum());
entry->set_file_size(file_resource.file_size());

// If file is removed completely, that information is only available in
// ChangeResource, and is reflected in |removed_|. If file is trashed, the
// file entry still exists but with its "trashed" label true.
entry->set_deleted(file_resource.labels().is_trashed());

// ImageMediaMetadata
entry->set_image_width(file_resource.image_media_metadata().width());
entry->set_image_height(file_resource.image_media_metadata().height());
entry->set_image_rotation(file_resource.image_media_metadata().rotation());

// CommonMetadata
entry->set_etag(file_resource.etag());
// entry->authors_
// entry->links_.
ScopedVector<google_apis::Link> links;
for (size_t i = 0; i < file_resource.parents().size(); ++i) {
google_apis::Link* link = new google_apis::Link;
link->set_type(google_apis::Link::LINK_PARENT);
link->set_href(file_resource.parents()[i].parent_link());
links.push_back(link);
}
if (!file_resource.alternate_link().is_empty()) {
google_apis::Link* link = new google_apis::Link;
link->set_type(google_apis::Link::LINK_ALTERNATE);
link->set_href(file_resource.alternate_link());
links.push_back(link);
}
entry->set_links(links.Pass());

// entry->categories_
entry->set_updated_time(file_resource.modified_date());
entry->set_last_viewed_time(file_resource.last_viewed_by_me_date());

entry->FillRemainingFields();
return entry.Pass();
}

scoped_ptr<google_apis::ResourceEntry>
ConvertChangeResourceToResourceEntry(
const google_apis::ChangeResource& change_resource) {
scoped_ptr<google_apis::ResourceEntry> entry;
if (change_resource.file())
entry = ConvertFileResourceToResourceEntry(*change_resource.file()).Pass();
else
entry.reset(new google_apis::ResourceEntry);

entry->set_resource_id(change_resource.file_id());
// If |is_deleted()| returns true, the file is removed from Drive.
entry->set_removed(change_resource.is_deleted());
entry->set_changestamp(change_resource.change_id());
entry->set_modification_date(change_resource.modification_date());

return entry.Pass();
}

scoped_ptr<google_apis::ResourceList>
ConvertFileListToResourceList(const google_apis::FileList& file_list) {
scoped_ptr<google_apis::ResourceList> feed(new google_apis::ResourceList);

const ScopedVector<google_apis::FileResource>& items = file_list.items();
ScopedVector<google_apis::ResourceEntry> entries;
for (size_t i = 0; i < items.size(); ++i)
entries.push_back(ConvertFileResourceToResourceEntry(*items[i]).release());
feed->set_entries(entries.Pass());

ScopedVector<google_apis::Link> links;
if (!file_list.next_link().is_empty()) {
google_apis::Link* link = new google_apis::Link;
link->set_type(google_apis::Link::LINK_NEXT);
link->set_href(file_list.next_link());
links.push_back(link);
}
feed->set_links(links.Pass());

return feed.Pass();
}

scoped_ptr<google_apis::ResourceList>
ConvertChangeListToResourceList(const google_apis::ChangeList& change_list) {
scoped_ptr<google_apis::ResourceList> feed(new google_apis::ResourceList);

const ScopedVector<google_apis::ChangeResource>& items = change_list.items();
ScopedVector<google_apis::ResourceEntry> entries;
for (size_t i = 0; i < items.size(); ++i) {
entries.push_back(
ConvertChangeResourceToResourceEntry(*items[i]).release());
}
feed->set_entries(entries.Pass());

feed->set_largest_changestamp(change_list.largest_change_id());

ScopedVector<google_apis::Link> links;
if (!change_list.next_link().is_empty()) {
google_apis::Link* link = new google_apis::Link;
link->set_type(google_apis::Link::LINK_NEXT);
link->set_href(change_list.next_link());
links.push_back(link);
}
feed->set_links(links.Pass());

return feed.Pass();
}

std::string GetMd5Digest(const base::FilePath& file_path) {
const int kBufferSize = 512 * 1024; // 512kB.

Expand Down
17 changes: 0 additions & 17 deletions chrome/browser/drive/drive_api_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ChangeResource;
class FileList;
class FileResource;
class ResourceEntry;
class ResourceList;
} // namespace google_apis

namespace drive {
Expand Down Expand Up @@ -57,9 +56,6 @@ std::string EscapeQueryStringValue(const std::string& str);
// See also: https://developers.google.com/drive/search-parameters
std::string TranslateQuery(const std::string& original_query);

// Extracts resource_id out of edit url.
std::string ExtractResourceIdFromUrl(const GURL& url);

// If |resource_id| is in the old resource ID format used by WAPI, converts it
// into the new format.
std::string CanonicalizeResourceId(const std::string& resource_id);
Expand All @@ -69,19 +65,6 @@ scoped_ptr<google_apis::ResourceEntry>
ConvertFileResourceToResourceEntry(
const google_apis::FileResource& file_resource);

// Converts ChangeResource to ResourceEntry.
scoped_ptr<google_apis::ResourceEntry>
ConvertChangeResourceToResourceEntry(
const google_apis::ChangeResource& change_resource);

// Converts FileList to ResourceList.
scoped_ptr<google_apis::ResourceList>
ConvertFileListToResourceList(const google_apis::FileList& file_list);

// Converts ChangeList to ResourceList.
scoped_ptr<google_apis::ResourceList>
ConvertChangeListToResourceList(const google_apis::ChangeList& change_list);

// Returns the (base-16 encoded) MD5 digest of the file content at |file_path|,
// or an empty string if an error is found.
std::string GetMd5Digest(const base::FilePath& file_path);
Expand Down
86 changes: 0 additions & 86 deletions chrome/browser/drive/drive_api_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "base/files/scoped_temp_dir.h"
#include "base/md5.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/gdata_wapi_parser.h"
#include "google_apis/drive/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
Expand Down Expand Up @@ -53,17 +52,6 @@ TEST(DriveApiUtilTest, TranslateQuery) {
EXPECT_EQ("fullText contains 'dog'", TranslateQuery("\"\" dog \"\""));
}

TEST(FileSystemUtilTest, ExtractResourceIdFromUrl) {
EXPECT_EQ("file:2_file_resource_id", ExtractResourceIdFromUrl(
GURL("https://file1_link_self/file:2_file_resource_id")));
// %3A should be unescaped.
EXPECT_EQ("file:2_file_resource_id", ExtractResourceIdFromUrl(
GURL("https://file1_link_self/file%3A2_file_resource_id")));

// The resource ID cannot be extracted, hence empty.
EXPECT_EQ("", ExtractResourceIdFromUrl(GURL("https://www.example.com/")));
}

TEST(FileSystemUtilTest, CanonicalizeResourceId) {
std::string resource_id("1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug");

Expand All @@ -79,80 +67,6 @@ TEST(FileSystemUtilTest, CanonicalizeResourceId) {
EXPECT_EQ(resource_id, CanonicalizeResourceId("externalapp:" + resource_id));
}

TEST(FileSystemUtilTest, ConvertFileResourceToResource_Parents) {
google_apis::FileResource file_resource;

std::vector<GURL> expected_links;
expected_links.push_back(GURL("http://server/id1"));
expected_links.push_back(GURL("http://server/id2"));
expected_links.push_back(GURL("http://server/id3"));

for (size_t i = 0; i < expected_links.size(); ++i) {
google_apis::ParentReference parent;
parent.set_parent_link(expected_links[i]);
file_resource.mutable_parents()->push_back(parent);
}

scoped_ptr<google_apis::ResourceEntry> entry(
ConvertFileResourceToResourceEntry(file_resource));
std::vector<GURL> actual_links;
for (size_t i = 0; i < entry->links().size(); ++i) {
if (entry->links()[i]->type() == google_apis::Link::LINK_PARENT)
actual_links.push_back(entry->links()[i]->href());
}

EXPECT_EQ(expected_links, actual_links);
}

TEST(FileSystemUtilTest, ConvertFileResourceToResourceEntryImageMediaMetadata) {
google_apis::FileResource file_resource_all_fields;
google_apis::FileResource file_resource_zero_fields;
google_apis::FileResource file_resource_no_fields;
// Set up FileResource instances;
{
{
google_apis::ImageMediaMetadata* image_media_metadata =
file_resource_all_fields.mutable_image_media_metadata();
image_media_metadata->set_width(640);
image_media_metadata->set_height(480);
image_media_metadata->set_rotation(90);
}
{
google_apis::ImageMediaMetadata* image_media_metadata =
file_resource_zero_fields.mutable_image_media_metadata();
image_media_metadata->set_width(0);
image_media_metadata->set_height(0);
image_media_metadata->set_rotation(0);
}
}

// Verify the converted values.
{
scoped_ptr<google_apis::ResourceEntry> resource_entry(
ConvertFileResourceToResourceEntry(file_resource_all_fields));

EXPECT_EQ(640, resource_entry->image_width());
EXPECT_EQ(480, resource_entry->image_height());
EXPECT_EQ(90, resource_entry->image_rotation());
}
{
scoped_ptr<google_apis::ResourceEntry> resource_entry(
ConvertFileResourceToResourceEntry(file_resource_zero_fields));

EXPECT_EQ(0, resource_entry->image_width());
EXPECT_EQ(0, resource_entry->image_height());
EXPECT_EQ(0, resource_entry->image_rotation());
}
{
scoped_ptr<google_apis::ResourceEntry> resource_entry(
ConvertFileResourceToResourceEntry(file_resource_no_fields));

EXPECT_EQ(-1, resource_entry->image_width());
EXPECT_EQ(-1, resource_entry->image_height());
EXPECT_EQ(-1, resource_entry->image_rotation());
}
}

TEST(DriveAPIUtilTest, GetMd5Digest) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class DriveUploaderInterface;

namespace google_apis {
class ResourceEntry;
class ResourceList;
}

namespace sync_file_system {
Expand Down
Loading

0 comments on commit 99daa8e

Please sign in to comment.