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

Side by Side Diff: chrome/browser/sync/engine/download_updates_command.cc

Issue 8189003: Send important client side event information to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: committing. Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/engine/download_updates_command.h" 5 #include "chrome/browser/sync/engine/download_updates_command.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/sync/engine/syncer.h" 10 #include "chrome/browser/sync/engine/syncer.h"
11 #include "chrome/browser/sync/engine/syncer_proto_util.h" 11 #include "chrome/browser/sync/engine/syncer_proto_util.h"
12 #include "chrome/browser/sync/engine/syncproto.h" 12 #include "chrome/browser/sync/engine/syncproto.h"
13 #include "chrome/browser/sync/syncable/directory_manager.h" 13 #include "chrome/browser/sync/syncable/directory_manager.h"
14 #include "chrome/browser/sync/syncable/model_type_payload_map.h" 14 #include "chrome/browser/sync/syncable/model_type_payload_map.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 16
17 using syncable::ScopedDirLookup; 17 using syncable::ScopedDirLookup;
18 18
19 using sync_pb::DebugInfo;
20
19 namespace browser_sync { 21 namespace browser_sync {
20 using sessions::StatusController; 22 using sessions::StatusController;
21 using sessions::SyncSession; 23 using sessions::SyncSession;
22 using std::string; 24 using std::string;
23 using syncable::FIRST_REAL_MODEL_TYPE; 25 using syncable::FIRST_REAL_MODEL_TYPE;
24 using syncable::MODEL_TYPE_COUNT; 26 using syncable::MODEL_TYPE_COUNT;
25 27
26 DownloadUpdatesCommand::DownloadUpdatesCommand() {} 28 DownloadUpdatesCommand::DownloadUpdatesCommand() {}
27 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} 29 DownloadUpdatesCommand::~DownloadUpdatesCommand() {}
28 30
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 get_updates->set_fetch_folders(true); 78 get_updates->set_fetch_folders(true);
77 79
78 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. 80 // Set GetUpdatesMessage.GetUpdatesCallerInfo information.
79 get_updates->mutable_caller_info()->set_source( 81 get_updates->mutable_caller_info()->set_source(
80 session->TestAndSetSource().updates_source); 82 session->TestAndSetSource().updates_source);
81 get_updates->mutable_caller_info()->set_notifications_enabled( 83 get_updates->mutable_caller_info()->set_notifications_enabled(
82 session->context()->notifications_enabled()); 84 session->context()->notifications_enabled());
83 85
84 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); 86 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message);
85 87
88 DebugInfo* debug_info = client_to_server_message.mutable_debug_info();
89
90 AppendClientDebugInfoIfNeeded(session, debug_info);
91
86 bool ok = SyncerProtoUtil::PostClientToServerMessage( 92 bool ok = SyncerProtoUtil::PostClientToServerMessage(
87 client_to_server_message, 93 client_to_server_message,
88 &update_response, 94 &update_response,
89 session); 95 session);
90 96
91 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( 97 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString(
92 update_response); 98 update_response);
93 99
94 StatusController* status = session->status_controller(); 100 StatusController* status = session->status_controller();
95 status->set_updates_request_types(enabled_types); 101 status->set_updates_request_types(enabled_types);
(...skipping 23 matching lines...) Expand all
119 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 125 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
120 if (target_datatypes[i]) { 126 if (target_datatypes[i]) {
121 requested_type_count++; 127 requested_type_count++;
122 syncable::AddDefaultExtensionValue(syncable::ModelTypeFromInt(i), 128 syncable::AddDefaultExtensionValue(syncable::ModelTypeFromInt(i),
123 filter_protobuf); 129 filter_protobuf);
124 } 130 }
125 } 131 }
126 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; 132 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter.";
127 } 133 }
128 134
135 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded(
136 sessions::SyncSession* session,
137 DebugInfo* debug_info) {
138 // We want to send the debug info only once per sync cycle. Check if it has
139 // already been sent.
140 if (!session->status_controller()->debug_info_sent()) {
141 VLOG(1) << "Sending client debug info ...";
142 // could be null in some unit tests.
143 if (session->context()->debug_info_getter()) {
144 session->context()->debug_info_getter()->GetAndClearDebugInfo(
145 debug_info);
146 }
147 session->status_controller()->set_debug_info_sent();
148 }
149 }
150
151
129 } // namespace browser_sync 152 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/download_updates_command.h ('k') | chrome/browser/sync/engine/download_updates_command_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698