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

Side by Side Diff: google_apis/gcm/base/mcs_message.cc

Issue 1548673002: Switch to standard integer types in google_apis/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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 | « google_apis/gcm/base/mcs_message.h ('k') | google_apis/gcm/base/mcs_message_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "google_apis/gcm/base/mcs_message.h" 5 #include "google_apis/gcm/base/mcs_message.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "google_apis/gcm/base/mcs_util.h" 8 #include "google_apis/gcm/base/mcs_util.h"
9 9
10 namespace gcm { 10 namespace gcm {
11 11
12 MCSMessage::Core::Core() {} 12 MCSMessage::Core::Core() {}
13 13
14 MCSMessage::Core::Core(uint8 tag, 14 MCSMessage::Core::Core(uint8_t tag,
15 const google::protobuf::MessageLite& protobuf) { 15 const google::protobuf::MessageLite& protobuf) {
16 scoped_ptr<google::protobuf::MessageLite> owned_protobuf(protobuf.New()); 16 scoped_ptr<google::protobuf::MessageLite> owned_protobuf(protobuf.New());
17 owned_protobuf->CheckTypeAndMergeFrom(protobuf); 17 owned_protobuf->CheckTypeAndMergeFrom(protobuf);
18 protobuf_ = owned_protobuf.Pass(); 18 protobuf_ = owned_protobuf.Pass();
19 } 19 }
20 20
21 MCSMessage::Core::Core( 21 MCSMessage::Core::Core(
22 uint8 tag, 22 uint8_t tag,
23 scoped_ptr<const google::protobuf::MessageLite> protobuf) { 23 scoped_ptr<const google::protobuf::MessageLite> protobuf) {
24 protobuf_ = protobuf.Pass(); 24 protobuf_ = protobuf.Pass();
25 } 25 }
26 26
27 MCSMessage::Core::~Core() {} 27 MCSMessage::Core::~Core() {}
28 28
29 const google::protobuf::MessageLite& MCSMessage::Core::Get() const { 29 const google::protobuf::MessageLite& MCSMessage::Core::Get() const {
30 return *protobuf_; 30 return *protobuf_;
31 } 31 }
32 32
33 MCSMessage::MCSMessage() : tag_(0), size_(0) {} 33 MCSMessage::MCSMessage() : tag_(0), size_(0) {}
34 34
35 MCSMessage::MCSMessage(const google::protobuf::MessageLite& protobuf) 35 MCSMessage::MCSMessage(const google::protobuf::MessageLite& protobuf)
36 : tag_(GetMCSProtoTag(protobuf)), 36 : tag_(GetMCSProtoTag(protobuf)),
37 size_(protobuf.ByteSize()), 37 size_(protobuf.ByteSize()),
38 core_(new Core(tag_, protobuf)) { 38 core_(new Core(tag_, protobuf)) {
39 } 39 }
40 40
41 MCSMessage::MCSMessage(uint8 tag, 41 MCSMessage::MCSMessage(uint8_t tag,
42 const google::protobuf::MessageLite& protobuf) 42 const google::protobuf::MessageLite& protobuf)
43 : tag_(tag), 43 : tag_(tag), size_(protobuf.ByteSize()), core_(new Core(tag_, protobuf)) {
44 size_(protobuf.ByteSize()),
45 core_(new Core(tag_, protobuf)) {
46 DCHECK_EQ(tag, GetMCSProtoTag(protobuf)); 44 DCHECK_EQ(tag, GetMCSProtoTag(protobuf));
47 } 45 }
48 46
49 MCSMessage::MCSMessage(uint8 tag, 47 MCSMessage::MCSMessage(uint8_t tag,
50 scoped_ptr<const google::protobuf::MessageLite> protobuf) 48 scoped_ptr<const google::protobuf::MessageLite> protobuf)
51 : tag_(tag), 49 : tag_(tag),
52 size_(protobuf->ByteSize()), 50 size_(protobuf->ByteSize()),
53 core_(new Core(tag_, protobuf.Pass())) { 51 core_(new Core(tag_, protobuf.Pass())) {
54 DCHECK_EQ(tag, GetMCSProtoTag(core_->Get())); 52 DCHECK_EQ(tag, GetMCSProtoTag(core_->Get()));
55 } 53 }
56 54
57 MCSMessage::~MCSMessage() { 55 MCSMessage::~MCSMessage() {
58 } 56 }
59 57
60 bool MCSMessage::IsValid() const { 58 bool MCSMessage::IsValid() const {
61 return core_.get() != NULL; 59 return core_.get() != NULL;
62 } 60 }
63 61
64 std::string MCSMessage::SerializeAsString() const { 62 std::string MCSMessage::SerializeAsString() const {
65 return core_->Get().SerializeAsString(); 63 return core_->Get().SerializeAsString();
66 } 64 }
67 65
68 const google::protobuf::MessageLite& MCSMessage::GetProtobuf() const { 66 const google::protobuf::MessageLite& MCSMessage::GetProtobuf() const {
69 return core_->Get(); 67 return core_->Get();
70 } 68 }
71 69
72 scoped_ptr<google::protobuf::MessageLite> MCSMessage::CloneProtobuf() const { 70 scoped_ptr<google::protobuf::MessageLite> MCSMessage::CloneProtobuf() const {
73 scoped_ptr<google::protobuf::MessageLite> clone(GetProtobuf().New()); 71 scoped_ptr<google::protobuf::MessageLite> clone(GetProtobuf().New());
74 clone->CheckTypeAndMergeFrom(GetProtobuf()); 72 clone->CheckTypeAndMergeFrom(GetProtobuf());
75 return clone.Pass(); 73 return clone.Pass();
76 } 74 }
77 75
78 } // namespace gcm 76 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/base/mcs_message.h ('k') | google_apis/gcm/base/mcs_message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698