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

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

Issue 7861013: Fix the false-positive detection of commit errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt at detecting errors 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/clear_data_command.h" 5 #include "chrome/browser/sync/engine/clear_data_command.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/sync/engine/syncer.h" 9 #include "chrome/browser/sync/engine/syncer.h"
10 #include "chrome/browser/sync/engine/syncer_proto_util.h" 10 #include "chrome/browser/sync/engine/syncer_proto_util.h"
11 #include "chrome/browser/sync/engine/syncproto.h" 11 #include "chrome/browser/sync/engine/syncproto.h"
12 #include "chrome/browser/sync/sessions/sync_session.h" 12 #include "chrome/browser/sync/sessions/sync_session.h"
13 #include "chrome/browser/sync/syncable/directory_manager.h" 13 #include "chrome/browser/sync/syncable/directory_manager.h"
14 14
15 using syncable::ScopedDirLookup; 15 using syncable::ScopedDirLookup;
16 16
17 namespace browser_sync { 17 namespace browser_sync {
18 18
19 using sessions::StatusController; 19 using sessions::StatusController;
20 using sessions::SyncSession; 20 using sessions::SyncSession;
21 using std::string; 21 using std::string;
22 using syncable::FIRST_REAL_MODEL_TYPE; 22 using syncable::FIRST_REAL_MODEL_TYPE;
23 using syncable::MODEL_TYPE_COUNT; 23 using syncable::MODEL_TYPE_COUNT;
24 24
25 25
26 ClearDataCommand::ClearDataCommand() {} 26 ClearDataCommand::ClearDataCommand() {}
27 ClearDataCommand::~ClearDataCommand() {} 27 ClearDataCommand::~ClearDataCommand() {}
28 28
29 void ClearDataCommand::ExecuteImpl(SyncSession* session) { 29 void ClearDataCommand::ExecuteImpl(SyncSession* session) {
30 StatusController* status = session->status_controller();
30 ClientToServerMessage client_to_server_message; 31 ClientToServerMessage client_to_server_message;
31 ClientToServerResponse client_to_server_response; 32 ClientToServerResponse client_to_server_response;
33 SyncOperationResult result;
32 34
33 client_to_server_message.set_share(session->context()->account_name()); 35 client_to_server_message.set_share(session->context()->account_name());
34 client_to_server_message.set_message_contents( 36 client_to_server_message.set_message_contents(
35 ClientToServerMessage::CLEAR_DATA); 37 ClientToServerMessage::CLEAR_DATA);
36 38
37 client_to_server_message.mutable_clear_user_data(); 39 client_to_server_message.mutable_clear_user_data();
38 40
39 ScopedDirLookup dir(session->context()->directory_manager(), 41 ScopedDirLookup dir(session->context()->directory_manager(),
40 session->context()->account_name()); 42 session->context()->account_name());
41 if (!dir.good()) { 43 if (!dir.good()) {
42 LOG(ERROR) << "Scoped dir lookup failed!"; 44 LOG(ERROR) << "Scoped dir lookup failed!";
45 result.error_type = DIRECTORY_LOOKUP_FAILED;
46 status->set_last_clear_data_result(result);
43 return; 47 return;
44 } 48 }
45 49
46 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); 50 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message);
47 51
48 VLOG(1) << "Clearing server data"; 52 VLOG(1) << "Clearing server data";
49 53
50 bool ok = SyncerProtoUtil::PostClientToServerMessage( 54 result = SyncerProtoUtil::PostClientToServerMessage(
51 client_to_server_message, 55 client_to_server_message,
52 &client_to_server_response, 56 &client_to_server_response,
53 session); 57 session);
58 status->set_last_clear_data_result(result);
54 59
55 DVLOG(1) << SyncerProtoUtil::ClientToServerResponseDebugString( 60 DVLOG(1) << SyncerProtoUtil::ClientToServerResponseDebugString(
56 client_to_server_response); 61 client_to_server_response);
57 62
58 // Clear pending indicates that the server has received our clear message 63 // NOTE: This code is broken. error_code() is deprecated. Fixing this
59 if (!ok || !client_to_server_response.has_error_code() || 64 // is a separate issue that I don't want to get into.
65
66 // Clear pending indicates that the server has received our clear message.
67 if (result.error_type != OPERATION_SUCCESS ||
68 // TODO(rlarocque): This code depends on deprecated error variables.
69 !client_to_server_response.has_error_code() ||
60 client_to_server_response.error_code() != 70 client_to_server_response.error_code() !=
61 sync_pb::ClientToServerResponse::SUCCESS) { 71 sync_pb::ClientToServerResponse::SUCCESS) {
62 // On failure, subsequent requests to the server will cause it to attempt 72 // On failure, subsequent requests to the server will cause it to attempt
63 // to resume the clear. The client will handle disabling of sync in 73 // to resume the clear. The client will handle disabling of sync in
64 // response to a store birthday error from the server. 74 // response to a store birthday error from the server.
65 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_FAILED); 75 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_FAILED);
66 session->context()->NotifyListeners(event); 76 session->context()->NotifyListeners(event);
67 77
68 LOG(ERROR) << "Error posting ClearData."; 78 LOG(ERROR) << "Error posting ClearData.";
69 79
70 return; 80 return;
71 } 81 }
72 82
73 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED); 83 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED);
74 session->context()->NotifyListeners(event); 84 session->context()->NotifyListeners(event);
75 85
76 session->delegate()->OnShouldStopSyncingPermanently(); 86 session->delegate()->OnShouldStopSyncingPermanently();
77 87
78 VLOG(1) << "ClearData succeeded."; 88 VLOG(1) << "ClearData succeeded.";
79 } 89 }
80 90
81 } // namespace browser_sync 91 } // namespace browser_sync
82 92
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/sync/engine/download_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698