| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file has the functions to log all the sync related HTTP communication. | 5 // This file has the functions to log all the sync related HTTP communication. |
| 6 // To get the log run a debug build of chrome with the flag | 6 // To get the log run a debug build of chrome with the flag |
| 7 // --vmodule=traffic_logger=1. | 7 // --vmodule=traffic_logger=1. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_LOGGER_H_ | 9 #ifndef CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_LOGGER_H_ |
| 10 #define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_LOGGER_H_ | 10 #define CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_LOGGER_H_ |
| 11 #pragma once | 11 #pragma once |
| 12 | 12 |
| 13 #include <string> |
| 14 |
| 13 namespace sync_pb { | 15 namespace sync_pb { |
| 14 class ClientToServerResponse; | 16 class ClientToServerResponse; |
| 15 class ClientToServerMessage; | 17 class ClientToServerMessage; |
| 16 } // namespace sync_pb | 18 } // namespace sync_pb |
| 17 | 19 |
| 18 namespace browser_sync { | 20 namespace browser_sync { |
| 19 | 21 |
| 20 void LogClientToServerMessage(const sync_pb::ClientToServerMessage& msg); | 22 namespace sessions { |
| 23 class SyncSession; |
| 24 } // namespace sessions |
| 25 |
| 26 enum TrafficMessageType { |
| 27 CLIENT_TO_SERVER_MESSAGE, |
| 28 CLIENT_TO_SERVER_RESPONSE, |
| 29 UNKNOWN_MESSAGE_TYPE |
| 30 }; |
| 31 |
| 32 struct TrafficRecord { |
| 33 // The serialized message. |
| 34 std::string message; |
| 35 TrafficMessageType message_type; |
| 36 // If the message is too big to be kept in memory then it would be trucated. |
| 37 // For now the entire message would be truncated if it is big. |
| 38 // TODO(lipalani): Truncate the specifics to fit with in size. |
| 39 bool truncated; |
| 40 |
| 41 TrafficRecord(const std::string& message, |
| 42 TrafficMessageType message_type, |
| 43 bool truncated); |
| 44 TrafficRecord(); |
| 45 ~TrafficRecord(); |
| 46 }; |
| 47 |
| 48 void LogClientToServerMessage(const sync_pb::ClientToServerMessage& msg, |
| 49 sessions::SyncSession* session); |
| 21 void LogClientToServerResponse( | 50 void LogClientToServerResponse( |
| 22 const sync_pb::ClientToServerResponse& response); | 51 const sync_pb::ClientToServerResponse& response, |
| 52 sessions::SyncSession* session); |
| 23 | 53 |
| 24 } // namespace browser_sync | 54 } // namespace browser_sync |
| 25 | 55 |
| 26 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_LOGGER_H_ | 56 #endif // CHROME_BROWSER_SYNC_ENGINE_TRAFFIC_LOGGER_H_ |
| OLD | NEW |