| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_SESSIONS_SESSION_COMMAND_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_COMMAND_H_ |
| 6 #define CHROME_BROWSER_SESSIONS_SESSION_COMMAND_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_COMMAND_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 class Pickle; | 12 class Pickle; |
| 13 | 13 |
| 14 // SessionCommand contains a command id and arbitrary chunk of data. The id | 14 // SessionCommand contains a command id and arbitrary chunk of data. The id |
| 15 // and chunk of data are specific to the service creating them. | 15 // and chunk of data are specific to the service creating them. |
| 16 // | 16 // |
| 17 // Both TabRestoreService and SessionService use SessionCommands to represent | 17 // Both TabRestoreService and SessionService use SessionCommands to represent |
| 18 // state on disk. | 18 // state on disk. |
| 19 // | 19 // |
| 20 // There are two ways to create a SessionCommand: | 20 // There are two ways to create a SessionCommand: |
| 21 // . Specificy the size of the data block to create. This is useful for | 21 // . Specificy the size of the data block to create. This is useful for |
| 22 // commands that have a fixed size. | 22 // commands that have a fixed size. |
| 23 // . From a pickle, this is useful for commands whose length varies. | 23 // . From a pickle, this is useful for commands whose length varies. |
| 24 class SessionCommand { | 24 class SessionCommand { |
| 25 public: | 25 public: |
| 26 // These get written to disk, so we define types for them. | 26 // These get written to disk, so we define types for them. |
| 27 // Type for the identifier. | 27 // Type for the identifier. |
| 28 typedef uint8 id_type; | 28 typedef uint8 id_type; |
| 29 |
| 29 // Type for writing the size. | 30 // Type for writing the size. |
| 30 typedef uint16 size_type; | 31 typedef uint16 size_type; |
| 31 | 32 |
| 32 // Creates a session command with the specified id. This allocates a buffer | 33 // Creates a session command with the specified id. This allocates a buffer |
| 33 // of size |size| that must be filled via contents(). | 34 // of size |size| that must be filled via contents(). |
| 34 SessionCommand(id_type id, size_type size); | 35 SessionCommand(id_type id, size_type size); |
| 35 | 36 |
| 36 // Convenience constructor that creates a session command with the specified | 37 // Convenience constructor that creates a session command with the specified |
| 37 // id whose contents is populated from the contents of pickle. | 38 // id whose contents is populated from the contents of pickle. |
| 38 SessionCommand(id_type id, const Pickle& pickle); | 39 SessionCommand(id_type id, const Pickle& pickle); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 58 Pickle* PayloadAsPickle() const; | 59 Pickle* PayloadAsPickle() const; |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 const id_type id_; | 62 const id_type id_; |
| 62 std::string contents_; | 63 std::string contents_; |
| 63 | 64 |
| 64 DISALLOW_COPY_AND_ASSIGN(SessionCommand); | 65 DISALLOW_COPY_AND_ASSIGN(SessionCommand); |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 #endif // CHROME_BROWSER_SESSIONS_SESSION_COMMAND_H_ | 68 #endif // CHROME_BROWSER_SESSIONS_SESSION_COMMAND_H_ |
| OLD | NEW |