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

Side by Side Diff: chrome/browser/sync/sync_stopped_reporter.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 "chrome/browser/sync/sync_stopped_reporter.h" 5 #include "chrome/browser/sync/sync_stopped_reporter.h"
6 6
7 #include "base/location.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h"
8 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/thread_task_runner_handle.h"
9 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
10 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
11 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
12 #include "net/http/http_status_code.h" 15 #include "net/http/http_status_code.h"
13 #include "net/url_request/url_fetcher.h" 16 #include "net/url_request/url_fetcher.h"
14 #include "net/url_request/url_request_context_getter.h" 17 #include "net/url_request/url_request_context_getter.h"
15 #include "sync/protocol/sync.pb.h" 18 #include "sync/protocol/sync.pb.h"
16 19
17 namespace { 20 namespace {
18 const char kEventEndpoint[] = "event"; 21 const char kEventEndpoint[] = "event";
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 timer_.Start(FROM_HERE, kRequestTimeout, this, 71 timer_.Start(FROM_HERE, kRequestTimeout, this,
69 &SyncStoppedReporter::OnTimeout); 72 &SyncStoppedReporter::OnTimeout);
70 } 73 }
71 74
72 void SyncStoppedReporter::OnURLFetchComplete(const net::URLFetcher* source) { 75 void SyncStoppedReporter::OnURLFetchComplete(const net::URLFetcher* source) {
73 Result result = source->GetResponseCode() == net::HTTP_OK 76 Result result = source->GetResponseCode() == net::HTTP_OK
74 ? RESULT_SUCCESS : RESULT_ERROR; 77 ? RESULT_SUCCESS : RESULT_ERROR;
75 fetcher_.reset(); 78 fetcher_.reset();
76 timer_.Stop(); 79 timer_.Stop();
77 if (!callback_.is_null()) { 80 if (!callback_.is_null()) {
78 base::MessageLoop::current()->PostTask(FROM_HERE, 81 base::ThreadTaskRunnerHandle::Get()->PostTask(
79 base::Bind(callback_, result)); 82 FROM_HERE, base::Bind(callback_, result));
80 } 83 }
81 } 84 }
82 85
83 void SyncStoppedReporter::OnTimeout() { 86 void SyncStoppedReporter::OnTimeout() {
84 fetcher_.reset(); 87 fetcher_.reset();
85 if (!callback_.is_null()) { 88 if (!callback_.is_null()) {
86 base::MessageLoop::current()->PostTask(FROM_HERE, 89 base::ThreadTaskRunnerHandle::Get()->PostTask(
87 base::Bind(callback_, RESULT_TIMEOUT)); 90 FROM_HERE, base::Bind(callback_, RESULT_TIMEOUT));
88 } 91 }
89 } 92 }
90 93
91 // Static. 94 // Static.
92 GURL SyncStoppedReporter::GetSyncEventURL(const GURL& sync_service_url) { 95 GURL SyncStoppedReporter::GetSyncEventURL(const GURL& sync_service_url) {
93 std::string path = sync_service_url.path(); 96 std::string path = sync_service_url.path();
94 if (path.empty() || *path.rbegin() != '/') { 97 if (path.empty() || *path.rbegin() != '/') {
95 path += '/'; 98 path += '/';
96 } 99 }
97 path += kEventEndpoint; 100 path += kEventEndpoint;
98 GURL::Replacements replacements; 101 GURL::Replacements replacements;
99 replacements.SetPathStr(path); 102 replacements.SetPathStr(path);
100 return sync_service_url.ReplaceComponents(replacements); 103 return sync_service_url.ReplaceComponents(replacements);
101 } 104 }
102 105
103 void SyncStoppedReporter::SetTimerTaskRunnerForTest( 106 void SyncStoppedReporter::SetTimerTaskRunnerForTest(
104 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 107 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
105 timer_.SetTaskRunner(task_runner); 108 timer_.SetTaskRunner(task_runner);
106 } 109 }
107 110
108 } // namespace browser_sync 111 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/startup_controller.cc ('k') | chrome/browser/sync/test/integration/sessions_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698