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

Side by Side Diff: components/sync/driver/sync_stopped_reporter.cc

Issue 2203673002: [Sync] Move //components/sync_driver to //components/sync/driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sd-a
Patch Set: Full change rebased on static lib. 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "components/sync_driver/sync_stopped_reporter.h" 5 #include "components/sync/driver/sync_stopped_reporter.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "components/sync/protocol/sync.pb.h" 13 #include "components/sync/protocol/sync.pb.h"
14 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
15 #include "net/http/http_status_code.h" 15 #include "net/http/http_status_code.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 fetcher_ = 66 fetcher_ =
67 net::URLFetcher::Create(sync_event_url_, net::URLFetcher::POST, this); 67 net::URLFetcher::Create(sync_event_url_, net::URLFetcher::POST, this);
68 fetcher_->AddExtraRequestHeader(base::StringPrintf( 68 fetcher_->AddExtraRequestHeader(base::StringPrintf(
69 "%s: Bearer %s", net::HttpRequestHeaders::kAuthorization, 69 "%s: Bearer %s", net::HttpRequestHeaders::kAuthorization,
70 access_token.c_str())); 70 access_token.c_str()));
71 fetcher_->AddExtraRequestHeader(base::StringPrintf( 71 fetcher_->AddExtraRequestHeader(base::StringPrintf(
72 "%s: %s", net::HttpRequestHeaders::kUserAgent, user_agent_.c_str())); 72 "%s: %s", net::HttpRequestHeaders::kUserAgent, user_agent_.c_str()));
73 fetcher_->SetRequestContext(request_context_.get()); 73 fetcher_->SetRequestContext(request_context_.get());
74 fetcher_->SetUploadData("application/octet-stream", msg); 74 fetcher_->SetUploadData("application/octet-stream", msg);
75 fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | 75 fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE |
76 net::LOAD_DISABLE_CACHE |
77 net::LOAD_DO_NOT_SAVE_COOKIES | 76 net::LOAD_DO_NOT_SAVE_COOKIES |
78 net::LOAD_DO_NOT_SEND_COOKIES); 77 net::LOAD_DO_NOT_SEND_COOKIES);
79 fetcher_->Start(); 78 fetcher_->Start();
80 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kRequestTimeoutSeconds), 79 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kRequestTimeoutSeconds),
81 this, &SyncStoppedReporter::OnTimeout); 80 this, &SyncStoppedReporter::OnTimeout);
82 } 81 }
83 82
84 void SyncStoppedReporter::OnURLFetchComplete(const net::URLFetcher* source) { 83 void SyncStoppedReporter::OnURLFetchComplete(const net::URLFetcher* source) {
85 Result result = source->GetResponseCode() == net::HTTP_OK 84 Result result =
86 ? RESULT_SUCCESS : RESULT_ERROR; 85 source->GetResponseCode() == net::HTTP_OK ? RESULT_SUCCESS : RESULT_ERROR;
87 fetcher_.reset(); 86 fetcher_.reset();
88 timer_.Stop(); 87 timer_.Stop();
89 if (!callback_.is_null()) { 88 if (!callback_.is_null()) {
90 base::ThreadTaskRunnerHandle::Get()->PostTask( 89 base::ThreadTaskRunnerHandle::Get()->PostTask(
91 FROM_HERE, base::Bind(callback_, result)); 90 FROM_HERE, base::Bind(callback_, result));
92 } 91 }
93 } 92 }
94 93
95 void SyncStoppedReporter::OnTimeout() { 94 void SyncStoppedReporter::OnTimeout() {
96 fetcher_.reset(); 95 fetcher_.reset();
(...skipping 14 matching lines...) Expand all
111 replacements.SetPathStr(path); 110 replacements.SetPathStr(path);
112 return sync_service_url.ReplaceComponents(replacements); 111 return sync_service_url.ReplaceComponents(replacements);
113 } 112 }
114 113
115 void SyncStoppedReporter::SetTimerTaskRunnerForTest( 114 void SyncStoppedReporter::SetTimerTaskRunnerForTest(
116 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 115 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
117 timer_.SetTaskRunner(task_runner); 116 timer_.SetTaskRunner(task_runner);
118 } 117 }
119 118
120 } // namespace browser_sync 119 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync/driver/sync_stopped_reporter.h ('k') | components/sync/driver/sync_stopped_reporter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698