OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef LIBRARIES_NACL_IO_GOOGLEDRIVEFS_UTIL_H_ |
| 6 #define LIBRARIES_NACL_IO_GOOGLEDRIVEFS_UTIL_H_ |
| 7 |
| 8 #include <stdlib.h> |
| 9 |
| 10 #include "nacl_io/error.h" |
| 11 #include "nacl_io/filesystem.h" |
| 12 #include "nacl_io/path.h" |
| 13 #include "nacl_io/pepper_interface.h" |
| 14 |
| 15 namespace nacl_io { |
| 16 |
| 17 class GoogleDriveFs; |
| 18 |
| 19 extern const char FOLDER_MIME_TYPE[]; |
| 20 extern const char DRIVE_URL[]; |
| 21 extern const char UPLOAD_DRIVE_URL[]; |
| 22 extern const char DOWNLOAD_DRIVE_URL[]; |
| 23 |
| 24 struct RequestUrlParams { |
| 25 std::string url; |
| 26 std::string method; |
| 27 std::string headers; |
| 28 std::string body; |
| 29 }; |
| 30 |
| 31 std::string ParentEqualClause(const std::string& parent_dir_id); |
| 32 std::string NameEqualClause(const std::string& name); |
| 33 |
| 34 int ExtractYearFromRFC3339(const std::string& date_time); |
| 35 int ExtractMonthFromRFC3339(const std::string& date_time); |
| 36 int ExtractDayFromRFC3339(const std::string& date_time); |
| 37 int ExtractHourFromRFC3339(const std::string& date_time); |
| 38 int ExtractMinuteFromRFC3339(const std::string& date_time); |
| 39 int ExtractSecondFromRFC3339(const std::string& date_time); |
| 40 |
| 41 time_t ConvertDateTimeToEpochTime(int year, |
| 42 int month, |
| 43 int day, |
| 44 int hour, |
| 45 int minute, |
| 46 int second); |
| 47 |
| 48 void AddUrlPath(const std::string& path, std::string* out_url); |
| 49 void AddUrlQAttributeValue(std::string* array, |
| 50 size_t size, |
| 51 std::string* out_q_attribute_value); |
| 52 void AddUrlFirstQueryParameter(const std::string& attribute, |
| 53 const std::string& value, |
| 54 std::string* out_url); |
| 55 void AddUrlNextQueryParameter(const std::string& attribute, |
| 56 const std::string& value, |
| 57 std::string* out_url); |
| 58 void AddHeaders(const std::string& header_field_key, |
| 59 const std::string& header_field_value, |
| 60 std::string* out_headers); |
| 61 void AddBody(const std::string& data, std::string* out_body); |
| 62 Error LoadUrl(PepperInterface* ppapi, |
| 63 const RequestUrlParams& params, |
| 64 ScopedResource* out_url_response_info_resource); |
| 65 Error ReadResponseBody(PepperInterface* ppapi, |
| 66 PP_Resource url_response_info_object, |
| 67 int32_t bytes_to_read, |
| 68 std::string* out_output); |
| 69 int32_t ReadStatusCode(PepperInterface* ppapi, |
| 70 PP_Resource url_response_info_object); |
| 71 Error GetValueStringAndValuePos(const std::string& json, |
| 72 const std::string& key, |
| 73 size_t key_search_pos, |
| 74 std::string* out_value_string, |
| 75 size_t* out_value_pos); |
| 76 Error RequestItemIdAndItemType(const std::string& parent_dir_id, |
| 77 const std::string& item_name, |
| 78 GoogleDriveFs* googledrivefs, |
| 79 std::string* out_item_id, |
| 80 bool* out_is_dir_type); |
| 81 Error RequestParentDirId(const Path& path, |
| 82 GoogleDriveFs* googledrivefs, |
| 83 std::string* out_parent_dir_id); |
| 84 } // namespace nacl_io |
| 85 |
| 86 #endif // LIBRARIES_NACL_IO_GOOGLEDRIVEFS_UTIL_H_ |
OLD | NEW |