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

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

Issue 9158004: Detect sync server communication errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for review comments Created 8 years, 11 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 | chrome/browser/sync/engine/download_updates_command.cc » ('j') | no next file with comments »
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 "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"
(...skipping 29 matching lines...) Expand all
40 session->context()->account_name()); 40 session->context()->account_name());
41 if (!dir.good()) { 41 if (!dir.good()) {
42 LOG(ERROR) << "Scoped dir lookup failed!"; 42 LOG(ERROR) << "Scoped dir lookup failed!";
43 return DIRECTORY_LOOKUP_FAILED; 43 return DIRECTORY_LOOKUP_FAILED;
44 } 44 }
45 45
46 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); 46 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message);
47 47
48 DVLOG(1) << "Clearing server data"; 48 DVLOG(1) << "Clearing server data";
49 49
50 bool ok = SyncerProtoUtil::PostClientToServerMessage( 50 SyncerError result = SyncerProtoUtil::PostClientToServerMessage(
51 client_to_server_message, 51 client_to_server_message,
52 &client_to_server_response, 52 &client_to_server_response,
53 session); 53 session);
54 54
55 DVLOG(1) << SyncerProtoUtil::ClientToServerResponseDebugString( 55 DVLOG(1) << SyncerProtoUtil::ClientToServerResponseDebugString(
56 client_to_server_response); 56 client_to_server_response);
57 57
58 // TODO(lipalani): This code is wrong. The response error codes it checks 58 // TODO(lipalani): This code is wrong. The response error codes it checks
59 // have been obsoleted. The only reason it hasn't caused problems is that 59 // have been obsoleted. The only reason it hasn't caused problems is that
60 // this code is unreachable. We should do something to clean up this mess. 60 // this code is unreachable. We should do something to clean up this mess.
61 // See also: crbug.com/71616. 61 // See also: crbug.com/71616.
62 // 62 //
63 // Clear pending indicates that the server has received our clear message 63 // Clear pending indicates that the server has received our clear message
64 if (!ok || !client_to_server_response.has_error_code() || 64 if (result != SYNCER_OK || !client_to_server_response.has_error_code() ||
65 client_to_server_response.error_code() != sync_pb::SyncEnums::SUCCESS) { 65 client_to_server_response.error_code() != sync_pb::SyncEnums::SUCCESS) {
66 // On failure, subsequent requests to the server will cause it to attempt 66 // On failure, subsequent requests to the server will cause it to attempt
67 // to resume the clear. The client will handle disabling of sync in 67 // to resume the clear. The client will handle disabling of sync in
68 // response to a store birthday error from the server. 68 // response to a store birthday error from the server.
69 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_FAILED); 69 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_FAILED);
70 session->context()->NotifyListeners(event); 70 session->context()->NotifyListeners(event);
71 71
72 LOG(ERROR) << "Error posting ClearData."; 72 LOG(ERROR) << "Error posting ClearData.";
73 73
74 return SYNCER_OK; 74 return result;
75 } 75 }
76 76
77 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED); 77 SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED);
78 session->context()->NotifyListeners(event); 78 session->context()->NotifyListeners(event);
79 79
80 session->delegate()->OnShouldStopSyncingPermanently(); 80 session->delegate()->OnShouldStopSyncingPermanently();
81 81
82 DVLOG(1) << "ClearData succeeded."; 82 DVLOG(1) << "ClearData succeeded.";
83 return SYNCER_OK; 83 return SYNCER_OK;
84 } 84 }
85 85
86 } // namespace browser_sync 86 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/engine/download_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698