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

Side by Side Diff: google_apis/drive/base_requests.h

Issue 1053623004: Drive: Add multipart related utility methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | google_apis/drive/base_requests.cc » ('j') | 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 // This file provides base classes used to issue HTTP requests for Google 5 // This file provides base classes used to issue HTTP requests for Google
6 // APIs. 6 // APIs.
7 7
8 #ifndef GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 8 #ifndef GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
10 10
(...skipping 12 matching lines...) Expand all
23 23
24 namespace base { 24 namespace base {
25 class Value; 25 class Value;
26 } // namespace base 26 } // namespace base
27 27
28 namespace google_apis { 28 namespace google_apis {
29 29
30 class FileResource; 30 class FileResource;
31 class RequestSender; 31 class RequestSender;
32 32
33 // Content type for multipart body.
34 enum MultipartType {
35 MULTIPART_RELATED,
36 MULTIPART_MIXED
37 };
38
39 // Pair of content type and data.
40 struct ContentTypeAndData {
41 std::string type;
42 std::string data;
43 };
44
33 typedef base::Callback<void(DriveApiErrorCode)> PrepareCallback; 45 typedef base::Callback<void(DriveApiErrorCode)> PrepareCallback;
34 46
35 // Callback used for requests that the server returns FileResource data 47 // Callback used for requests that the server returns FileResource data
36 // formatted into JSON value. 48 // formatted into JSON value.
37 typedef base::Callback<void(DriveApiErrorCode error, 49 typedef base::Callback<void(DriveApiErrorCode error,
38 scoped_ptr<FileResource> entry)> 50 scoped_ptr<FileResource> entry)>
39 FileResourceCallback; 51 FileResourceCallback;
40 52
41 // Callback used for DownloadFileRequest and ResumeUploadRequestBase. 53 // Callback used for DownloadFileRequest and ResumeUploadRequestBase.
42 typedef base::Callback<void(int64 progress, int64 total)> ProgressCallback; 54 typedef base::Callback<void(int64 progress, int64 total)> ProgressCallback;
43 55
44 // Callback used to get the content from DownloadFileRequest. 56 // Callback used to get the content from DownloadFileRequest.
45 typedef base::Callback<void( 57 typedef base::Callback<void(
46 DriveApiErrorCode error, 58 DriveApiErrorCode error,
47 scoped_ptr<std::string> content)> GetContentCallback; 59 scoped_ptr<std::string> content)> GetContentCallback;
48 60
49 // Parses JSON passed in |json|. Returns NULL on failure. 61 // Parses JSON passed in |json|. Returns NULL on failure.
50 scoped_ptr<base::Value> ParseJson(const std::string& json); 62 scoped_ptr<base::Value> ParseJson(const std::string& json);
51 63
64 // Generate multipart body. If |predetermined_boundary| is not empty, it uses
65 // the string as boundary. Otherwise it generates random boundary that does not
66 // conflict with |parts|.
67 void GenerateMultipartBody(MultipartType multipart_type,
68 const std::string& predetermined_boundary,
69 const std::vector<ContentTypeAndData>& parts,
70 ContentTypeAndData* output);
71
52 //======================= AuthenticatedRequestInterface ====================== 72 //======================= AuthenticatedRequestInterface ======================
53 73
54 // An interface class for implementing a request which requires OAuth2 74 // An interface class for implementing a request which requires OAuth2
55 // authentication. 75 // authentication.
56 class AuthenticatedRequestInterface { 76 class AuthenticatedRequestInterface {
57 public: 77 public:
58 // Called when re-authentication is required. See Start() for details. 78 // Called when re-authentication is required. See Start() for details.
59 typedef base::Callback<void(AuthenticatedRequestInterface* request)> 79 typedef base::Callback<void(AuthenticatedRequestInterface* request)>
60 ReAuthenticateCallback; 80 ReAuthenticateCallback;
61 81
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 const ProgressCallback progress_callback_; 592 const ProgressCallback progress_callback_;
573 const GURL download_url_; 593 const GURL download_url_;
574 const base::FilePath output_file_path_; 594 const base::FilePath output_file_path_;
575 595
576 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); 596 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase);
577 }; 597 };
578 598
579 } // namespace google_apis 599 } // namespace google_apis
580 600
581 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 601 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
OLDNEW
« no previous file with comments | « no previous file | google_apis/drive/base_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698