OLD | NEW |
1 // Copyright 2006 The Chromium Authors. All rights reserved. | 1 // Copyright 2006 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 COMPONENTS_SESSIONS_CORE_SESSION_COMMAND_H_ | 5 #ifndef COMPONENTS_SESSIONS_CORE_SESSION_COMMAND_H_ |
6 #define COMPONENTS_SESSIONS_CORE_SESSION_COMMAND_H_ | 6 #define COMPONENTS_SESSIONS_CORE_SESSION_COMMAND_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 | 12 |
10 #include "base/basictypes.h" | 13 #include "base/macros.h" |
11 #include "components/sessions/core/sessions_export.h" | 14 #include "components/sessions/core/sessions_export.h" |
12 | 15 |
13 namespace base { | 16 namespace base { |
14 class Pickle; | 17 class Pickle; |
15 } | 18 } |
16 | 19 |
17 namespace sessions { | 20 namespace sessions { |
18 | 21 |
19 // SessionCommand contains a command id and arbitrary chunk of data. The id | 22 // SessionCommand contains a command id and arbitrary chunk of data. The id |
20 // and chunk of data are specific to the service creating them. | 23 // and chunk of data are specific to the service creating them. |
21 // | 24 // |
22 // Both TabRestoreService and SessionService use SessionCommands to represent | 25 // Both TabRestoreService and SessionService use SessionCommands to represent |
23 // state on disk. | 26 // state on disk. |
24 // | 27 // |
25 // There are two ways to create a SessionCommand: | 28 // There are two ways to create a SessionCommand: |
26 // . Specifiy the size of the data block to create. This is useful for | 29 // . Specifiy the size of the data block to create. This is useful for |
27 // commands that have a fixed size. | 30 // commands that have a fixed size. |
28 // . From a pickle, this is useful for commands whose length varies. | 31 // . From a pickle, this is useful for commands whose length varies. |
29 class SESSIONS_EXPORT SessionCommand { | 32 class SESSIONS_EXPORT SessionCommand { |
30 public: | 33 public: |
31 // These get written to disk, so we define types for them. | 34 // These get written to disk, so we define types for them. |
32 // Type for the identifier. | 35 // Type for the identifier. |
33 typedef uint8 id_type; | 36 typedef uint8_t id_type; |
34 | 37 |
35 // Type for writing the size. | 38 // Type for writing the size. |
36 typedef uint16 size_type; | 39 typedef uint16_t size_type; |
37 | 40 |
38 // Creates a session command with the specified id. This allocates a buffer | 41 // Creates a session command with the specified id. This allocates a buffer |
39 // of size |size| that must be filled via contents(). | 42 // of size |size| that must be filled via contents(). |
40 SessionCommand(id_type id, size_type size); | 43 SessionCommand(id_type id, size_type size); |
41 | 44 |
42 // Convenience constructor that creates a session command with the specified | 45 // Convenience constructor that creates a session command with the specified |
43 // id whose contents is populated from the contents of pickle. | 46 // id whose contents is populated from the contents of pickle. |
44 SessionCommand(id_type id, const base::Pickle& pickle); | 47 SessionCommand(id_type id, const base::Pickle& pickle); |
45 | 48 |
46 // The contents of the command. | 49 // The contents of the command. |
(...skipping 19 matching lines...) Expand all Loading... |
66 private: | 69 private: |
67 const id_type id_; | 70 const id_type id_; |
68 std::string contents_; | 71 std::string contents_; |
69 | 72 |
70 DISALLOW_COPY_AND_ASSIGN(SessionCommand); | 73 DISALLOW_COPY_AND_ASSIGN(SessionCommand); |
71 }; | 74 }; |
72 | 75 |
73 } // namespace sessions | 76 } // namespace sessions |
74 | 77 |
75 #endif // COMPONENTS_SESSIONS_CORE_SESSION_COMMAND_H_ | 78 #endif // COMPONENTS_SESSIONS_CORE_SESSION_COMMAND_H_ |
OLD | NEW |