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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « sync/engine/clear_server_data.h ('k') | sync/engine/commit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sync/engine/clear_server_data.h"
6
7 #include "base/trace_event/trace_event.h"
8 #include "sync/engine/syncer.h"
9 #include "sync/engine/syncer_proto_util.h"
10 #include "sync/internal_api/public/events/clear_server_data_request_event.h"
11 #include "sync/internal_api/public/events/clear_server_data_response_event.h"
12 #include "sync/sessions/sync_session.h"
13
14 namespace syncer {
15
16 ClearServerData::ClearServerData(const std::string& account_name) {
17 request_.set_share(account_name);
18 request_.set_message_contents(
19 sync_pb::ClientToServerMessage::CLEAR_SERVER_DATA);
20 request_.mutable_clear_server_data();
21 }
22
23 ClearServerData::~ClearServerData() {}
24
25 SyncerError ClearServerData::SendRequest(sessions::SyncSession* session) {
26 if (session->context()->debug_info_getter()) {
27 sync_pb::DebugInfo* debug_info = request_.mutable_debug_info();
28 session->context()->debug_info_getter()->GetDebugInfo(debug_info);
29 }
30
31 DVLOG(1) << "Sending ClearServerData message.";
32
33 const ClearServerDataRequestEvent request_event(base::Time::Now(), request_);
34 session->SendProtocolEvent(request_event);
35
36 sync_pb::ClientToServerResponse response;
37
38 TRACE_EVENT_BEGIN0("sync", "PostClearServerData");
39 const SyncerError post_result = SyncerProtoUtil::PostClientToServerMessage(
40 &request_, &response, session, nullptr);
41 TRACE_EVENT_END0("sync", "PostClearServerData");
42
43 const ClearServerDataResponseEvent response_event(base::Time::Now(),
44 post_result, response);
45 session->SendProtocolEvent(response_event);
46
47 if (post_result != SYNCER_OK) {
48 DVLOG(1) << "Post ClearServerData failed";
49 return post_result;
50 }
51
52 if (!response.has_clear_server_data()) {
53 DVLOG(1) << "ClearServerData response has no ClearServerData body!";
54 return SERVER_RESPONSE_VALIDATION_FAILED;
55 }
56
57 if (session->context()->debug_info_getter()) {
58 DVLOG(1) << "Clearing client debug info.";
59 session->context()->debug_info_getter()->ClearDebugInfo();
60 }
61
62 return post_result;
63 }
64
65 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/clear_server_data.h ('k') | sync/engine/commit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698