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

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

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 5 years 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/gaia/ubertoken_fetcher.h ('k') | google_apis/gcm/base/mcs_message.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 #ifndef GOOGLE_APIS_GCM_BASE_MCS_MESSAGE_H_ 5 #ifndef GOOGLE_APIS_GCM_BASE_MCS_MESSAGE_H_
6 #define GOOGLE_APIS_GCM_BASE_MCS_MESSAGE_H_ 6 #define GOOGLE_APIS_GCM_BASE_MCS_MESSAGE_H_
7 7
8 #include <stdint.h>
9
8 #include <string> 10 #include <string>
9 11
10 #include "base/basictypes.h" 12 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "google_apis/gcm/base/gcm_export.h" 15 #include "google_apis/gcm/base/gcm_export.h"
14 16
15 namespace google { 17 namespace google {
16 namespace protobuf { 18 namespace protobuf {
17 class MessageLite; 19 class MessageLite;
18 } // namespace protobuf 20 } // namespace protobuf
19 } // namespace google 21 } // namespace google
20 22
21 namespace gcm { 23 namespace gcm {
22 24
23 // A wrapper for MCS protobuffers that encapsulates their tag, size and data 25 // A wrapper for MCS protobuffers that encapsulates their tag, size and data
24 // in an immutable and thread-safe format. If a mutable version is desired, 26 // in an immutable and thread-safe format. If a mutable version is desired,
25 // CloneProtobuf() should use used to create a new copy of the protobuf. 27 // CloneProtobuf() should use used to create a new copy of the protobuf.
26 // 28 //
27 // Note: default copy and assign welcome. 29 // Note: default copy and assign welcome.
28 class GCM_EXPORT MCSMessage { 30 class GCM_EXPORT MCSMessage {
29 public: 31 public:
30 // Creates an invalid MCSMessage. 32 // Creates an invalid MCSMessage.
31 MCSMessage(); 33 MCSMessage();
32 // Infers tag from |message|. 34 // Infers tag from |message|.
33 explicit MCSMessage(const google::protobuf::MessageLite& protobuf); 35 explicit MCSMessage(const google::protobuf::MessageLite& protobuf);
34 // |tag| must match |protobuf|'s message type. 36 // |tag| must match |protobuf|'s message type.
35 MCSMessage(uint8 tag, const google::protobuf::MessageLite& protobuf); 37 MCSMessage(uint8_t tag, const google::protobuf::MessageLite& protobuf);
36 // |tag| must match |protobuf|'s message type. Takes ownership of |protobuf|. 38 // |tag| must match |protobuf|'s message type. Takes ownership of |protobuf|.
37 MCSMessage(uint8 tag, 39 MCSMessage(uint8_t tag,
38 scoped_ptr<const google::protobuf::MessageLite> protobuf); 40 scoped_ptr<const google::protobuf::MessageLite> protobuf);
39 ~MCSMessage(); 41 ~MCSMessage();
40 42
41 // Returns whether this message is valid or not (whether a protobuf was 43 // Returns whether this message is valid or not (whether a protobuf was
42 // provided at construction time or not). 44 // provided at construction time or not).
43 bool IsValid() const; 45 bool IsValid() const;
44 46
45 // Getters for serialization. 47 // Getters for serialization.
46 uint8 tag() const { return tag_; } 48 uint8_t tag() const { return tag_; }
47 int size() const {return size_; } 49 int size() const {return size_; }
48 std::string SerializeAsString() const; 50 std::string SerializeAsString() const;
49 51
50 // Getter for accessing immutable probotuf fields. 52 // Getter for accessing immutable probotuf fields.
51 const google::protobuf::MessageLite& GetProtobuf() const; 53 const google::protobuf::MessageLite& GetProtobuf() const;
52 54
53 // Getter for creating a mutated version of the protobuf. 55 // Getter for creating a mutated version of the protobuf.
54 scoped_ptr<google::protobuf::MessageLite> CloneProtobuf() const; 56 scoped_ptr<google::protobuf::MessageLite> CloneProtobuf() const;
55 57
56 private: 58 private:
57 class Core : public base::RefCountedThreadSafe<MCSMessage::Core> { 59 class Core : public base::RefCountedThreadSafe<MCSMessage::Core> {
58 public: 60 public:
59 Core(); 61 Core();
60 Core(uint8 tag, const google::protobuf::MessageLite& protobuf); 62 Core(uint8_t tag, const google::protobuf::MessageLite& protobuf);
61 Core(uint8 tag, scoped_ptr<const google::protobuf::MessageLite> protobuf); 63 Core(uint8_t tag, scoped_ptr<const google::protobuf::MessageLite> protobuf);
62 64
63 const google::protobuf::MessageLite& Get() const; 65 const google::protobuf::MessageLite& Get() const;
64 66
65 private: 67 private:
66 friend class base::RefCountedThreadSafe<MCSMessage::Core>; 68 friend class base::RefCountedThreadSafe<MCSMessage::Core>;
67 ~Core(); 69 ~Core();
68 70
69 // The immutable protobuf. 71 // The immutable protobuf.
70 scoped_ptr<const google::protobuf::MessageLite> protobuf_; 72 scoped_ptr<const google::protobuf::MessageLite> protobuf_;
71 73
72 DISALLOW_COPY_AND_ASSIGN(Core); 74 DISALLOW_COPY_AND_ASSIGN(Core);
73 }; 75 };
74 76
75 // These are cached separately to avoid having to recompute them. 77 // These are cached separately to avoid having to recompute them.
76 const uint8 tag_; 78 const uint8_t tag_;
77 const int size_; 79 const int size_;
78 80
79 // The refcounted core, containing the protobuf memory. 81 // The refcounted core, containing the protobuf memory.
80 scoped_refptr<const Core> core_; 82 scoped_refptr<const Core> core_;
81 }; 83 };
82 84
83 } // namespace gcm 85 } // namespace gcm
84 86
85 #endif // GOOGLE_APIS_GCM_BASE_MCS_MESSAGE_H_ 87 #endif // GOOGLE_APIS_GCM_BASE_MCS_MESSAGE_H_
OLDNEW
« no previous file with comments | « google_apis/gaia/ubertoken_fetcher.h ('k') | google_apis/gcm/base/mcs_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698