OLD | NEW |
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/gdata/drive_api_operations.h" | 5 #include "chrome/browser/chromeos/gdata/drive_api_operations.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 "chrome/common/net/url_util.h" | 9 #include "chrome/common/net/url_util.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 const char kDriveV2AboutURL[] = "https://www.googleapis.com/drive/v2/about"; | 13 const char kDriveV2AboutURL[] = "https://www.googleapis.com/drive/v2/about"; |
14 const char kDriveV2ApplistURL[] = "https://www.googleapis.com/drive/v2/apps"; | 14 const char kDriveV2ApplistURL[] = "https://www.googleapis.com/drive/v2/apps"; |
15 const char kDriveV2ChangelistURL[] = | 15 const char kDriveV2ChangelistURL[] = |
16 "https://www.googleapis.com/drive/v2/changes"; | 16 "https://www.googleapis.com/drive/v2/changes"; |
17 | 17 |
18 const char kDriveV2FilelistURL[] = "https://www.googleapis.com/drive/v2/files"; | 18 const char kDriveV2FilelistURL[] = "https://www.googleapis.com/drive/v2/files"; |
19 const char kDriveV2FileURLFormat[] = | 19 const char kDriveV2FileURLFormat[] = |
20 "https://www.googleapis.com/drive/v2/files/%s"; | 20 "https://www.googleapis.com/drive/v2/files/%s"; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 // TODO(kochi): Rename to namespace drive. http://crbug.com/136371 | 24 // TODO(kochi): Rename to namespace drive. http://crbug.com/136371 |
25 namespace gdata { | 25 namespace gdata { |
26 | 26 |
27 //============================== GetAboutOperation ============================= | 27 //============================== GetAboutOperation ============================= |
28 | 28 |
29 GetAboutOperation::GetAboutOperation(GDataOperationRegistry* registry, | 29 GetAboutOperation::GetAboutOperation(OperationRegistry* registry, |
30 const GetDataCallback& callback) | 30 const GetDataCallback& callback) |
31 : GetDataOperation(registry, callback) {} | 31 : GetDataOperation(registry, callback) {} |
32 | 32 |
33 GetAboutOperation::~GetAboutOperation() {} | 33 GetAboutOperation::~GetAboutOperation() {} |
34 | 34 |
35 GURL GetAboutOperation::GetURL() const { | 35 GURL GetAboutOperation::GetURL() const { |
36 return GURL(kDriveV2AboutURL); | 36 return GURL(kDriveV2AboutURL); |
37 } | 37 } |
38 | 38 |
39 //============================== GetApplistOperation =========================== | 39 //============================== GetApplistOperation =========================== |
40 | 40 |
41 GetApplistOperation::GetApplistOperation(GDataOperationRegistry* registry, | 41 GetApplistOperation::GetApplistOperation(OperationRegistry* registry, |
42 const GetDataCallback& callback) | 42 const GetDataCallback& callback) |
43 : GetDataOperation(registry, callback) {} | 43 : GetDataOperation(registry, callback) {} |
44 | 44 |
45 GetApplistOperation::~GetApplistOperation() {} | 45 GetApplistOperation::~GetApplistOperation() {} |
46 | 46 |
47 GURL GetApplistOperation::GetURL() const { | 47 GURL GetApplistOperation::GetURL() const { |
48 return GURL(kDriveV2ApplistURL); | 48 return GURL(kDriveV2ApplistURL); |
49 } | 49 } |
50 | 50 |
51 //============================ GetChangelistOperation ========================== | 51 //============================ GetChangelistOperation ========================== |
52 | 52 |
53 GetChangelistOperation::GetChangelistOperation( | 53 GetChangelistOperation::GetChangelistOperation( |
54 GDataOperationRegistry* registry, | 54 OperationRegistry* registry, |
55 const GURL& url, | 55 const GURL& url, |
56 int64 start_changestamp, | 56 int64 start_changestamp, |
57 const GetDataCallback& callback) | 57 const GetDataCallback& callback) |
58 : GetDataOperation(registry, callback), | 58 : GetDataOperation(registry, callback), |
59 url_(kDriveV2ChangelistURL), | 59 url_(kDriveV2ChangelistURL), |
60 start_changestamp_(start_changestamp) { | 60 start_changestamp_(start_changestamp) { |
61 if (!url.is_empty()) | 61 if (!url.is_empty()) |
62 url_ = url; | 62 url_ = url; |
63 } | 63 } |
64 | 64 |
65 GetChangelistOperation::~GetChangelistOperation() {} | 65 GetChangelistOperation::~GetChangelistOperation() {} |
66 | 66 |
67 GURL GetChangelistOperation::GetURL() const { | 67 GURL GetChangelistOperation::GetURL() const { |
68 if (start_changestamp_) | 68 if (start_changestamp_) |
69 return chrome_common_net::AppendOrReplaceQueryParameter( | 69 return chrome_common_net::AppendOrReplaceQueryParameter( |
70 url_, "startChangeId", base::Int64ToString(start_changestamp_)); | 70 url_, "startChangeId", base::Int64ToString(start_changestamp_)); |
71 return url_; | 71 return url_; |
72 } | 72 } |
73 | 73 |
74 //============================= GetFlielistOperation =========================== | 74 //============================= GetFlielistOperation =========================== |
75 | 75 |
76 GetFilelistOperation::GetFilelistOperation( | 76 GetFilelistOperation::GetFilelistOperation( |
77 GDataOperationRegistry* registry, | 77 OperationRegistry* registry, |
78 const GURL& url, | 78 const GURL& url, |
79 const std::string& search_string, | 79 const std::string& search_string, |
80 const GetDataCallback& callback) | 80 const GetDataCallback& callback) |
81 : GetDataOperation(registry, callback), | 81 : GetDataOperation(registry, callback), |
82 url_(kDriveV2FilelistURL), | 82 url_(kDriveV2FilelistURL), |
83 search_string_(search_string) { | 83 search_string_(search_string) { |
84 if (!url.is_empty()) | 84 if (!url.is_empty()) |
85 url_ = url; | 85 url_ = url; |
86 } | 86 } |
87 | 87 |
88 GetFilelistOperation::~GetFilelistOperation() {} | 88 GetFilelistOperation::~GetFilelistOperation() {} |
89 | 89 |
90 GURL GetFilelistOperation::GetURL() const { | 90 GURL GetFilelistOperation::GetURL() const { |
91 if (!search_string_.empty()) { | 91 if (!search_string_.empty()) { |
92 return chrome_common_net::AppendOrReplaceQueryParameter( | 92 return chrome_common_net::AppendOrReplaceQueryParameter( |
93 url_, "q", search_string_); | 93 url_, "q", search_string_); |
94 } | 94 } |
95 return url_; | 95 return url_; |
96 } | 96 } |
97 | 97 |
98 //=============================== GetFlieOperation ============================= | 98 //=============================== GetFlieOperation ============================= |
99 | 99 |
100 GetFileOperation::GetFileOperation( | 100 GetFileOperation::GetFileOperation( |
101 GDataOperationRegistry* registry, | 101 OperationRegistry* registry, |
102 const std::string& file_id, | 102 const std::string& file_id, |
103 const GetDataCallback& callback) | 103 const GetDataCallback& callback) |
104 : GetDataOperation(registry, callback), | 104 : GetDataOperation(registry, callback), |
105 file_id_(file_id) {} | 105 file_id_(file_id) {} |
106 | 106 |
107 GetFileOperation::~GetFileOperation() {} | 107 GetFileOperation::~GetFileOperation() {} |
108 | 108 |
109 GURL GetFileOperation::GetURL() const { | 109 GURL GetFileOperation::GetURL() const { |
110 return GURL(base::StringPrintf(kDriveV2FileURLFormat, file_id_.c_str())); | 110 return GURL(base::StringPrintf(kDriveV2FileURLFormat, file_id_.c_str())); |
111 } | 111 } |
112 | 112 |
113 } // namespace gdata | 113 } // namespace gdata |
OLD | NEW |