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

Side by Side Diff: sync/engine/syncer_proto_util.cc

Issue 9732008: [Sync] Store the past 10 traffic records in memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sync/engine/traffic_logger.cc » ('j') | sync/engine/traffic_recorder.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "sync/engine/syncer_proto_util.h" 5 #include "sync/engine/syncer_proto_util.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "sync/engine/net/server_connection_manager.h" 9 #include "sync/engine/net/server_connection_manager.h"
10 #include "sync/engine/syncer.h" 10 #include "sync/engine/syncer.h"
11 #include "sync/engine/syncer_types.h" 11 #include "sync/engine/syncer_types.h"
12 #include "sync/engine/traffic_logger.h" 12 #include "sync/engine/traffic_logger.h"
13 #include "sync/engine/traffic_recorder.h"
13 #include "sync/protocol/service_constants.h" 14 #include "sync/protocol/service_constants.h"
14 #include "sync/protocol/sync.pb.h" 15 #include "sync/protocol/sync.pb.h"
15 #include "sync/protocol/sync_enums.pb.h" 16 #include "sync/protocol/sync_enums.pb.h"
16 #include "sync/protocol/sync_protocol_error.h" 17 #include "sync/protocol/sync_protocol_error.h"
17 #include "sync/sessions/sync_session.h" 18 #include "sync/sessions/sync_session.h"
18 #include "sync/syncable/model_type.h" 19 #include "sync/syncable/model_type.h"
19 #include "sync/syncable/syncable-inl.h" 20 #include "sync/syncable/syncable-inl.h"
20 #include "sync/syncable/syncable.h" 21 #include "sync/syncable/syncable.h"
21 #include "sync/util/time.h" 22 #include "sync/util/time.h"
22 23
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 333
333 CHECK(response); 334 CHECK(response);
334 DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated. 335 DCHECK(!msg.get_updates().has_from_timestamp()); // Deprecated.
335 DCHECK(!msg.get_updates().has_requested_types()); // Deprecated. 336 DCHECK(!msg.get_updates().has_requested_types()); // Deprecated.
336 DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg)) 337 DCHECK(msg.has_store_birthday() || IsVeryFirstGetUpdates(msg))
337 << "Must call AddRequestBirthday to set birthday."; 338 << "Must call AddRequestBirthday to set birthday.";
338 339
339 syncable::Directory* dir = session->context()->directory(); 340 syncable::Directory* dir = session->context()->directory();
340 341
341 LogClientToServerMessage(msg); 342 LogClientToServerMessage(msg);
343 session->context()->traffic_recorder()->RecordClientToServerMessage(msg);
342 if (!PostAndProcessHeaders(session->context()->connection_manager(), session, 344 if (!PostAndProcessHeaders(session->context()->connection_manager(), session,
343 msg, response)) { 345 msg, response)) {
344 // There was an error establishing communication with the server. 346 // There was an error establishing communication with the server.
345 // We can not proceed beyond this point. 347 // We can not proceed beyond this point.
346 const browser_sync::HttpResponse::ServerConnectionCode server_status = 348 const browser_sync::HttpResponse::ServerConnectionCode server_status =
347 session->context()->connection_manager()->server_status(); 349 session->context()->connection_manager()->server_status();
348 350
349 DCHECK_NE(server_status, browser_sync::HttpResponse::NONE); 351 DCHECK_NE(server_status, browser_sync::HttpResponse::NONE);
350 DCHECK_NE(server_status, browser_sync::HttpResponse::SERVER_CONNECTION_OK); 352 DCHECK_NE(server_status, browser_sync::HttpResponse::SERVER_CONNECTION_OK);
351 353
352 return ServerConnectionErrorAsSyncerError(server_status); 354 return ServerConnectionErrorAsSyncerError(server_status);
353 } 355 }
354 356
355 LogClientToServerResponse(*response); 357 LogClientToServerResponse(*response);
358 session->context()->traffic_recorder()->RecordClientToServerResponse(
359 *response);
356 360
357 browser_sync::SyncProtocolError sync_protocol_error; 361 browser_sync::SyncProtocolError sync_protocol_error;
358 362
359 // Birthday mismatch overrides any error that is sent by the server. 363 // Birthday mismatch overrides any error that is sent by the server.
360 if (!VerifyResponseBirthday(dir, response)) { 364 if (!VerifyResponseBirthday(dir, response)) {
361 sync_protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY; 365 sync_protocol_error.error_type = browser_sync::NOT_MY_BIRTHDAY;
362 sync_protocol_error.action = 366 sync_protocol_error.action =
363 browser_sync::DISABLE_SYNC_ON_CLIENT; 367 browser_sync::DISABLE_SYNC_ON_CLIENT;
364 } else if (response->has_error()) { 368 } else if (response->has_error()) {
365 // This is a new server. Just get the error from the protocol. 369 // This is a new server. Just get the error from the protocol.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 536 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
533 const sync_pb::ClientToServerResponse& response) { 537 const sync_pb::ClientToServerResponse& response) {
534 // Add more handlers as needed. 538 // Add more handlers as needed.
535 std::string output; 539 std::string output;
536 if (response.has_get_updates()) 540 if (response.has_get_updates())
537 output.append(GetUpdatesResponseString(response.get_updates())); 541 output.append(GetUpdatesResponseString(response.get_updates()));
538 return output; 542 return output;
539 } 543 }
540 544
541 } // namespace browser_sync 545 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | sync/engine/traffic_logger.cc » ('j') | sync/engine/traffic_recorder.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698