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

Side by Side Diff: chrome/browser/google_apis/drive_api_url_generator.cc

Issue 12225101: Implement GetInitiateUpload{New,Existing}FileUrl on Drive API v2. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148632_replace_url_to_resource_id_2
Patch Set: Created 7 years, 10 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
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/google_apis/drive_api_url_generator.h" 5 #include "chrome/browser/google_apis/drive_api_url_generator.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "net/base/escape.h" 9 #include "net/base/escape.h"
10 #include "net/base/url_util.h" 10 #include "net/base/url_util.h"
11 11
12 namespace google_apis { 12 namespace google_apis {
13 13
14 namespace { 14 namespace {
15 15
16 // Hard coded URLs for communication with a google drive server. 16 // Hard coded URLs for communication with a google drive server.
17 const char kDriveV2AboutUrl[] = "/drive/v2/about"; 17 const char kDriveV2AboutUrl[] = "/drive/v2/about";
18 const char kDriveV2ApplistUrl[] = "/drive/v2/apps"; 18 const char kDriveV2ApplistUrl[] = "/drive/v2/apps";
19 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; 19 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes";
20 const char kDriveV2FilelistUrl[] = "/drive/v2/files"; 20 const char kDriveV2FilelistUrl[] = "/drive/v2/files";
21 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; 21 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/";
22 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; 22 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children";
23 const char kDriveV2ChildrenUrlForRemovalFormat[] = 23 const char kDriveV2ChildrenUrlForRemovalFormat[] =
24 "/drive/v2/files/%s/children/%s"; 24 "/drive/v2/files/%s/children/%s";
25 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; 25 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash";
26 const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files";
27 const char kDriveV2InitiateUploadExistingFileUrlPrefix[] =
28 "/upload/drive/v2/files/";
29
30 GURL AddResumableUploadParam(const GURL& url) {
31 return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable");
32 }
26 33
27 } // namespace 34 } // namespace
28 35
29 DriveApiUrlGenerator::DriveApiUrlGenerator(const GURL& base_url) 36 DriveApiUrlGenerator::DriveApiUrlGenerator(const GURL& base_url)
30 : base_url_(base_url) { 37 : base_url_(base_url) {
31 // Do nothing. 38 // Do nothing.
32 } 39 }
33 40
34 DriveApiUrlGenerator::~DriveApiUrlGenerator() { 41 DriveApiUrlGenerator::~DriveApiUrlGenerator() {
35 // Do nothing. 42 // Do nothing.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 96 }
90 97
91 GURL DriveApiUrlGenerator::GetChildrenUrlForRemoval( 98 GURL DriveApiUrlGenerator::GetChildrenUrlForRemoval(
92 const std::string& folder_id, const std::string& child_id) const { 99 const std::string& folder_id, const std::string& child_id) const {
93 return base_url_.Resolve( 100 return base_url_.Resolve(
94 base::StringPrintf(kDriveV2ChildrenUrlForRemovalFormat, 101 base::StringPrintf(kDriveV2ChildrenUrlForRemovalFormat,
95 net::EscapePath(folder_id).c_str(), 102 net::EscapePath(folder_id).c_str(),
96 net::EscapePath(child_id).c_str())); 103 net::EscapePath(child_id).c_str()));
97 } 104 }
98 105
106 GURL DriveApiUrlGenerator::GetInitiateUploadNewFileUrl() const {
107 return AddResumableUploadParam(
108 base_url_.Resolve(kDriveV2InitiateUploadNewFileUrl));
109 }
110
111 GURL DriveApiUrlGenerator::GetInitiateUploadExistingFileUrl(
112 const std::string& resource_id) const {
113 const GURL& url = base_url_.Resolve(
114 kDriveV2InitiateUploadExistingFileUrlPrefix +
115 net::EscapePath(resource_id));
116 return AddResumableUploadParam(url);
117 }
118
99 } // namespace google_apis 119 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/drive_api_url_generator.h ('k') | chrome/browser/google_apis/drive_api_url_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698