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

Side by Side Diff: remoting/protocol/message_serialization.h

Issue 2748203002: Remove usage of USE_SYSTEM_PROTOBUF (Closed)
Patch Set: Rebase Created 3 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 | « remoting/protocol/message_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 defines utility methods used for encoding and decoding the protocol 5 // This file defines utility methods used for encoding and decoding the protocol
6 // used in Chromoting. 6 // used in Chromoting.
7 7
8 #ifndef REMOTING_PROTOCOL_MESSAGE_SERIALIZATION_H_ 8 #ifndef REMOTING_PROTOCOL_MESSAGE_SERIALIZATION_H_
9 #define REMOTING_PROTOCOL_MESSAGE_SERIALIZATION_H_ 9 #define REMOTING_PROTOCOL_MESSAGE_SERIALIZATION_H_
10 10
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "remoting/base/compound_buffer.h" 12 #include "remoting/base/compound_buffer.h"
13
14 #if defined(USE_SYSTEM_PROTOBUF)
15 #include <google/protobuf/message_lite.h>
16 #else
17 #include "third_party/protobuf/src/google/protobuf/message_lite.h" 13 #include "third_party/protobuf/src/google/protobuf/message_lite.h"
18 #endif
19 14
20 namespace remoting { 15 namespace remoting {
21 namespace protocol { 16 namespace protocol {
22 17
23 template <class T> 18 template <class T>
24 std::unique_ptr<T> ParseMessage(CompoundBuffer* buffer) { 19 std::unique_ptr<T> ParseMessage(CompoundBuffer* buffer) {
25 std::unique_ptr<T> message(new T()); 20 std::unique_ptr<T> message(new T());
26 CompoundBufferInputStream stream(buffer); 21 CompoundBufferInputStream stream(buffer);
27 if (!message->ParseFromZeroCopyStream(&stream)) { 22 if (!message->ParseFromZeroCopyStream(&stream)) {
28 LOG(WARNING) << "Received message that is not a valid protocol buffer."; 23 LOG(WARNING) << "Received message that is not a valid protocol buffer.";
29 return nullptr; 24 return nullptr;
30 } 25 }
31 DCHECK_EQ(stream.position(), buffer->total_bytes()); 26 DCHECK_EQ(stream.position(), buffer->total_bytes());
32 return message; 27 return message;
33 } 28 }
34 29
35 // Serialize the Protocol Buffer message and provide sufficient framing for 30 // Serialize the Protocol Buffer message and provide sufficient framing for
36 // sending it over the wire. 31 // sending it over the wire.
37 // This will provide sufficient prefix and suffix for the receiver side to 32 // This will provide sufficient prefix and suffix for the receiver side to
38 // decode the message. 33 // decode the message.
39 scoped_refptr<net::IOBufferWithSize> SerializeAndFrameMessage( 34 scoped_refptr<net::IOBufferWithSize> SerializeAndFrameMessage(
40 const google::protobuf::MessageLite& msg); 35 const google::protobuf::MessageLite& msg);
41 36
42 } // namespace protocol 37 } // namespace protocol
43 } // namespace remoting 38 } // namespace remoting
44 39
45 #endif // REMOTING_PROTOCOL_MESSAGE_SERIALIZATION_H_ 40 #endif // REMOTING_PROTOCOL_MESSAGE_SERIALIZATION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/message_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698