| Index: native_client_sdk/src/libraries/nacl_io/googledrivefs/googledrivefs_util.h
|
| diff --git a/native_client_sdk/src/libraries/nacl_io/googledrivefs/googledrivefs_util.h b/native_client_sdk/src/libraries/nacl_io/googledrivefs/googledrivefs_util.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fb555c74455f06b6623db32d4a5711035b585129
|
| --- /dev/null
|
| +++ b/native_client_sdk/src/libraries/nacl_io/googledrivefs/googledrivefs_util.h
|
| @@ -0,0 +1,89 @@
|
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef LIBRARIES_NACL_IO_GOOGLEDRIVEFS_UTIL_H_
|
| +#define LIBRARIES_NACL_IO_GOOGLEDRIVEFS_UTIL_H_
|
| +
|
| +#include <stdlib.h>
|
| +
|
| +#include "nacl_io/error.h"
|
| +#include "nacl_io/filesystem.h"
|
| +#include "nacl_io/path.h"
|
| +#include "nacl_io/pepper_interface.h"
|
| +
|
| +namespace nacl_io {
|
| +
|
| +#define NACL_ARRAY_SIZE_UNSAFE(arr) ((sizeof arr) / sizeof arr[0])
|
| +
|
| +static const char FOLDER_MIME_TYPE[] = "application/vnd.google-apps.folder";
|
| +
|
| +static const char DRIVE_URL[] = "https://www.googleapis.com/drive/v3/files";
|
| +static const char UPLOAD_DRIVE_URL[] =
|
| + "https://www.googleapis.com/upload/drive/v3/files";
|
| +static const char DOWNLOAD_DRIVE_URL[] =
|
| + "https://www.googleapis.com/download/drive/v3/files";
|
| +
|
| +struct RequestUrlParams {
|
| + std::string url;
|
| + std::string method;
|
| + std::string headers;
|
| + std::string body;
|
| +};
|
| +
|
| +std::string ParentEqualClause(const std::string& parent_dir_id);
|
| +std::string NameEqualClause(const std::string& name);
|
| +
|
| +int ExtractYearFromRFC3339(const std::string& date_time);
|
| +int ExtractMonthFromRFC3339(const std::string& date_time);
|
| +int ExtractDayFromRFC3339(const std::string& date_time);
|
| +int ExtractHourFromRFC3339(const std::string& date_time);
|
| +int ExtractMinuteFromRFC3339(const std::string& date_time);
|
| +int ExtractSecondFromRFC3339(const std::string& date_time);
|
| +
|
| +time_t ConvertDateTimeToEpochTime(int year,
|
| + int month,
|
| + int day,
|
| + int hour,
|
| + int minute,
|
| + int second);
|
| +
|
| +void AddUrlPath(const std::string& path, std::string* out_url);
|
| +void AddUrlQAttributeValue(std::string* array,
|
| + size_t size,
|
| + std::string* out_q_attribute_value);
|
| +void AddUrlFirstQueryParameter(const std::string& attribute,
|
| + const std::string& value,
|
| + std::string* out_url);
|
| +void AddUrlNextQueryParameter(const std::string& attribute,
|
| + const std::string& value,
|
| + std::string* out_url);
|
| +void AddHeaders(const std::string& header_field_key,
|
| + const std::string& header_field_value,
|
| + std::string* out_headers);
|
| +void AddBody(const std::string& data, std::string* out_body);
|
| +Error LoadUrl(PepperInterface* ppapi,
|
| + const RequestUrlParams& params,
|
| + ScopedResource* out_url_response_info_resource);
|
| +Error ReadResponseBody(PepperInterface* ppapi,
|
| + PP_Resource url_response_info_object,
|
| + uint32_t bytes_to_read,
|
| + std::string* out_output);
|
| +int32_t ReadStatusCode(PepperInterface* ppapi,
|
| + PP_Resource url_response_info_object);
|
| +Error GetValueStringAndValuePos(const std::string& json,
|
| + const std::string& key,
|
| + size_t key_search_pos,
|
| + std::string* out_value_string,
|
| + size_t* out_value_pos);
|
| +Error RequestItemIdAndItemType(const std::string& parent_dir_id,
|
| + const std::string& item_name,
|
| + Filesystem* filesystem,
|
| + std::string* out_item_id,
|
| + bool* out_is_dir_type);
|
| +Error RequestParentDirId(const Path& path,
|
| + Filesystem* filesystem,
|
| + std::string* out_parent_dir_id);
|
| +} // namespace nacl_io
|
| +
|
| +#endif // LIBRARIES_NACL_IO_GOOGLEDRIVEFS_UTIL_H_
|
|
|