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

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

Issue 1547233002: Convert Pass()→std::move() in //google_apis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 <utility>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "google_apis/gcm/base/mcs_util.h" 10 #include "google_apis/gcm/base/mcs_util.h"
9 11
10 namespace gcm { 12 namespace gcm {
11 13
12 MCSMessage::Core::Core() {} 14 MCSMessage::Core::Core() {}
13 15
14 MCSMessage::Core::Core(uint8_t tag, 16 MCSMessage::Core::Core(uint8_t tag,
15 const google::protobuf::MessageLite& protobuf) { 17 const google::protobuf::MessageLite& protobuf) {
16 scoped_ptr<google::protobuf::MessageLite> owned_protobuf(protobuf.New()); 18 scoped_ptr<google::protobuf::MessageLite> owned_protobuf(protobuf.New());
17 owned_protobuf->CheckTypeAndMergeFrom(protobuf); 19 owned_protobuf->CheckTypeAndMergeFrom(protobuf);
18 protobuf_ = owned_protobuf.Pass(); 20 protobuf_ = std::move(owned_protobuf);
19 } 21 }
20 22
21 MCSMessage::Core::Core( 23 MCSMessage::Core::Core(
22 uint8_t tag, 24 uint8_t tag,
23 scoped_ptr<const google::protobuf::MessageLite> protobuf) { 25 scoped_ptr<const google::protobuf::MessageLite> protobuf) {
24 protobuf_ = protobuf.Pass(); 26 protobuf_ = std::move(protobuf);
25 } 27 }
26 28
27 MCSMessage::Core::~Core() {} 29 MCSMessage::Core::~Core() {}
28 30
29 const google::protobuf::MessageLite& MCSMessage::Core::Get() const { 31 const google::protobuf::MessageLite& MCSMessage::Core::Get() const {
30 return *protobuf_; 32 return *protobuf_;
31 } 33 }
32 34
33 MCSMessage::MCSMessage() : tag_(0), size_(0) {} 35 MCSMessage::MCSMessage() : tag_(0), size_(0) {}
34 36
35 MCSMessage::MCSMessage(const google::protobuf::MessageLite& protobuf) 37 MCSMessage::MCSMessage(const google::protobuf::MessageLite& protobuf)
36 : tag_(GetMCSProtoTag(protobuf)), 38 : tag_(GetMCSProtoTag(protobuf)),
37 size_(protobuf.ByteSize()), 39 size_(protobuf.ByteSize()),
38 core_(new Core(tag_, protobuf)) { 40 core_(new Core(tag_, protobuf)) {
39 } 41 }
40 42
41 MCSMessage::MCSMessage(uint8_t tag, 43 MCSMessage::MCSMessage(uint8_t tag,
42 const google::protobuf::MessageLite& protobuf) 44 const google::protobuf::MessageLite& protobuf)
43 : tag_(tag), size_(protobuf.ByteSize()), core_(new Core(tag_, protobuf)) { 45 : tag_(tag), size_(protobuf.ByteSize()), core_(new Core(tag_, protobuf)) {
44 DCHECK_EQ(tag, GetMCSProtoTag(protobuf)); 46 DCHECK_EQ(tag, GetMCSProtoTag(protobuf));
45 } 47 }
46 48
47 MCSMessage::MCSMessage(uint8_t tag, 49 MCSMessage::MCSMessage(uint8_t tag,
48 scoped_ptr<const google::protobuf::MessageLite> protobuf) 50 scoped_ptr<const google::protobuf::MessageLite> protobuf)
49 : tag_(tag), 51 : tag_(tag),
50 size_(protobuf->ByteSize()), 52 size_(protobuf->ByteSize()),
51 core_(new Core(tag_, protobuf.Pass())) { 53 core_(new Core(tag_, std::move(protobuf))) {
52 DCHECK_EQ(tag, GetMCSProtoTag(core_->Get())); 54 DCHECK_EQ(tag, GetMCSProtoTag(core_->Get()));
53 } 55 }
54 56
55 MCSMessage::~MCSMessage() { 57 MCSMessage::~MCSMessage() {
56 } 58 }
57 59
58 bool MCSMessage::IsValid() const { 60 bool MCSMessage::IsValid() const {
59 return core_.get() != NULL; 61 return core_.get() != NULL;
60 } 62 }
61 63
62 std::string MCSMessage::SerializeAsString() const { 64 std::string MCSMessage::SerializeAsString() const {
63 return core_->Get().SerializeAsString(); 65 return core_->Get().SerializeAsString();
64 } 66 }
65 67
66 const google::protobuf::MessageLite& MCSMessage::GetProtobuf() const { 68 const google::protobuf::MessageLite& MCSMessage::GetProtobuf() const {
67 return core_->Get(); 69 return core_->Get();
68 } 70 }
69 71
70 scoped_ptr<google::protobuf::MessageLite> MCSMessage::CloneProtobuf() const { 72 scoped_ptr<google::protobuf::MessageLite> MCSMessage::CloneProtobuf() const {
71 scoped_ptr<google::protobuf::MessageLite> clone(GetProtobuf().New()); 73 scoped_ptr<google::protobuf::MessageLite> clone(GetProtobuf().New());
72 clone->CheckTypeAndMergeFrom(GetProtobuf()); 74 clone->CheckTypeAndMergeFrom(GetProtobuf());
73 return clone.Pass(); 75 return clone;
74 } 76 }
75 77
76 } // namespace gcm 78 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gaia/oauth2_token_service_request.cc ('k') | google_apis/gcm/base/mcs_message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698