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

Unified Diff: third_party/grpc/include/grpc++/impl/codegen/proto_utils.h

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/include/grpc++/impl/codegen/proto_utils.h
diff --git a/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.cpp b/third_party/grpc/include/grpc++/impl/codegen/proto_utils.h
similarity index 50%
copy from third_party/WebKit/Source/web/WebFileChooserCompletionImpl.cpp
copy to third_party/grpc/include/grpc++/impl/codegen/proto_utils.h
index 4d5675d2549992da4a7b3e44a23398ffb4574116..ce177104e00dbdf0d4976cea826c827ad2901bd0 100644
--- a/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.cpp
+++ b/third_party/grpc/include/grpc++/impl/codegen/proto_utils.h
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Copyright 2015-2016, Google Inc.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,51 +28,49 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
*/
-#include "web/WebFileChooserCompletionImpl.h"
+#ifndef GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H
+#define GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H
+
+#include <type_traits>
-#include "platform/FileMetadata.h"
-#include "wtf/DateMath.h"
+#include <grpc/impl/codegen/byte_buffer.h>
+#include <grpc++/impl/codegen/serialization_traits.h>
+#include <grpc++/impl/codegen/config_protobuf.h>
+#include <grpc++/impl/codegen/status.h>
-namespace blink {
+namespace grpc {
-WebFileChooserCompletionImpl::WebFileChooserCompletionImpl(PassRefPtr<FileChooser> chooser)
- : m_fileChooser(chooser)
-{
-}
+// Serialize the msg into a buffer created inside the function. The caller
+// should destroy the returned buffer when done with it. If serialization fails,
+// false is returned and buffer is left unchanged.
+Status SerializeProto(const grpc::protobuf::Message& msg,
+ grpc_byte_buffer** buffer);
-WebFileChooserCompletionImpl::~WebFileChooserCompletionImpl()
-{
-}
+// The caller keeps ownership of buffer and msg.
+Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg,
+ int max_message_size);
-void WebFileChooserCompletionImpl::didChooseFile(const WebVector<WebString>& fileNames)
-{
- Vector<FileChooserFileInfo> fileInfo;
- for (size_t i = 0; i < fileNames.size(); ++i)
- fileInfo.append(FileChooserFileInfo(fileNames[i]));
- m_fileChooser->chooseFiles(fileInfo);
- // This object is no longer needed.
- delete this;
-}
+template <class T>
+class SerializationTraits<T, typename std::enable_if<std::is_base_of<
+ grpc::protobuf::Message, T>::value>::type> {
+ public:
+ static Status Serialize(const grpc::protobuf::Message& msg,
+ grpc_byte_buffer** buffer, bool* own_buffer) {
+ *own_buffer = true;
+ return SerializeProto(msg, buffer);
+ }
+ static Status Deserialize(grpc_byte_buffer* buffer,
+ grpc::protobuf::Message* msg,
+ int max_message_size) {
+ auto status = DeserializeProto(buffer, msg, max_message_size);
+ grpc_byte_buffer_destroy(buffer);
+ return status;
+ }
+};
-void WebFileChooserCompletionImpl::didChooseFile(const WebVector<SelectedFileInfo>& files)
-{
- Vector<FileChooserFileInfo> fileInfo;
- for (size_t i = 0; i < files.size(); ++i) {
- if (files[i].fileSystemURL.isEmpty()) {
- fileInfo.append(FileChooserFileInfo(files[i].path, files[i].displayName));
- } else {
- FileMetadata metadata;
- metadata.modificationTime = files[i].modificationTime * msPerSecond;
- metadata.length = files[i].length;
- metadata.type = files[i].isDirectory ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
- fileInfo.append(FileChooserFileInfo(files[i].fileSystemURL, metadata));
- }
- }
- m_fileChooser->chooseFiles(fileInfo);
- // This object is no longer needed.
- delete this;
-}
+} // namespace grpc
-} // namespace blink
+#endif // GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H

Powered by Google App Engine
This is Rietveld 408576698