OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * |
| 3 * Copyright 2015-2016, Google Inc. |
| 4 * All rights reserved. |
3 * | 5 * |
4 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
6 * met: | 8 * met: |
7 * | 9 * |
8 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 12 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 13 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 14 * in the documentation and/or other materials provided with the |
13 * distribution. | 15 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 16 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 17 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 18 * this software without specific prior written permission. |
17 * | 19 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 * |
29 */ | 32 */ |
30 | 33 |
31 #ifndef WebStorageQuotaCallbacks_h | 34 #ifndef GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H |
32 #define WebStorageQuotaCallbacks_h | 35 #define GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H |
33 | 36 |
34 #include "WebCommon.h" | 37 namespace grpc { |
35 #include "WebPrivatePtr.h" | |
36 #include "WebStorageQuotaError.h" | |
37 | 38 |
38 namespace blink { | 39 /// Defines how to serialize and deserialize some type. |
| 40 /// |
| 41 /// Used for hooking different message serialization API's into GRPC. |
| 42 /// Each SerializationTraits implementation must provide the following |
| 43 /// functions: |
| 44 /// static Status Serialize(const Message& msg, |
| 45 /// grpc_byte_buffer** buffer, |
| 46 // bool* own_buffer); |
| 47 /// static Status Deserialize(grpc_byte_buffer* buffer, |
| 48 /// Message* msg, |
| 49 /// int max_message_size); |
| 50 /// |
| 51 /// Serialize is required to convert message to a grpc_byte_buffer, and |
| 52 /// to store a pointer to that byte buffer at *buffer. *own_buffer should |
| 53 /// be set to true if the caller owns said byte buffer, or false if |
| 54 /// ownership is retained elsewhere. |
| 55 /// |
| 56 /// Deserialize is required to convert buffer into the message stored at |
| 57 /// msg. max_message_size is passed in as a bound on the maximum number of |
| 58 /// message bytes Deserialize should accept. |
| 59 /// |
| 60 /// Both functions return a Status, allowing them to explain what went |
| 61 /// wrong if required. |
| 62 template <class Message, |
| 63 class UnusedButHereForPartialTemplateSpecialization = void> |
| 64 class SerializationTraits; |
39 | 65 |
40 class StorageQuotaCallbacks; | 66 } // namespace grpc |
41 | 67 |
42 class WebStorageQuotaCallbacks { | 68 #endif // GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H |
43 public: | |
44 ~WebStorageQuotaCallbacks() { reset(); } | |
45 WebStorageQuotaCallbacks() { } | |
46 WebStorageQuotaCallbacks(const WebStorageQuotaCallbacks& c) { assign(c); } | |
47 WebStorageQuotaCallbacks& operator=(const WebStorageQuotaCallbacks& c) | |
48 { | |
49 assign(c); | |
50 return *this; | |
51 } | |
52 | |
53 BLINK_PLATFORM_EXPORT void reset(); | |
54 BLINK_PLATFORM_EXPORT void assign(const WebStorageQuotaCallbacks&); | |
55 | |
56 #if INSIDE_BLINK | |
57 BLINK_PLATFORM_EXPORT WebStorageQuotaCallbacks(StorageQuotaCallbacks*); | |
58 #endif | |
59 | |
60 // Callback for WebFrameClient::queryStorageUsageAndQuota. | |
61 BLINK_PLATFORM_EXPORT void didQueryStorageUsageAndQuota(unsigned long long u
sageInBytes, unsigned long long quotaInBytes); | |
62 | |
63 // Callback for WebFrameClient::requestStorageQuota. | |
64 // This may return a smaller amount of quota than the requested. | |
65 BLINK_PLATFORM_EXPORT void didGrantStorageQuota(unsigned long long usageInBy
tes, unsigned long long grantedQuotaInBytes); | |
66 | |
67 BLINK_PLATFORM_EXPORT void didFail(WebStorageQuotaError); | |
68 | |
69 private: | |
70 WebPrivatePtr<StorageQuotaCallbacks> m_private; | |
71 }; | |
72 | |
73 } // namespace blink | |
74 | |
75 #endif // WebStorageQuotaCallbacks_h | |
OLD | NEW |