OLD | NEW |
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 "components/sync/protocol/sync.pb.h" | 12 #include "components/sync/protocol/sync.pb.h" |
13 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
14 #include "net/http/http_status_code.h" | 14 #include "net/http/http_status_code.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const char kEventEndpoint[] = "event"; | 18 const char kEventEndpoint[] = "event"; |
19 | 19 |
20 // The request is tiny, so even on poor connections 10 seconds should be | 20 // The request is tiny, so even on poor connections 10 seconds should be |
21 // plenty of time. Since sync is off when this request is started, we don't | 21 // plenty of time. Since sync is off when this request is started, we don't |
22 // want anything sync-related hanging around for very long from a human | 22 // want anything sync-related hanging around for very long from a human |
23 // perspective either. This seems like a good compromise. | 23 // perspective either. This seems like a good compromise. |
24 const int kRequestTimeoutSeconds = 10; | 24 const int kRequestTimeoutSeconds = 10; |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 namespace browser_sync { | 28 namespace syncer { |
29 | 29 |
30 SyncStoppedReporter::SyncStoppedReporter( | 30 SyncStoppedReporter::SyncStoppedReporter( |
31 const GURL& sync_service_url, | 31 const GURL& sync_service_url, |
32 const std::string& user_agent, | 32 const std::string& user_agent, |
33 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 33 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
34 const ResultCallback& callback) | 34 const ResultCallback& callback) |
35 : sync_event_url_(GetSyncEventURL(sync_service_url)), | 35 : sync_event_url_(GetSyncEventURL(sync_service_url)), |
36 user_agent_(user_agent), | 36 user_agent_(user_agent), |
37 request_context_(request_context), | 37 request_context_(request_context), |
38 callback_(callback) { | 38 callback_(callback) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 GURL::Replacements replacements; | 106 GURL::Replacements replacements; |
107 replacements.SetPathStr(path); | 107 replacements.SetPathStr(path); |
108 return sync_service_url.ReplaceComponents(replacements); | 108 return sync_service_url.ReplaceComponents(replacements); |
109 } | 109 } |
110 | 110 |
111 void SyncStoppedReporter::SetTimerTaskRunnerForTest( | 111 void SyncStoppedReporter::SetTimerTaskRunnerForTest( |
112 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 112 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
113 timer_.SetTaskRunner(task_runner); | 113 timer_.SetTaskRunner(task_runner); |
114 } | 114 } |
115 | 115 |
116 } // namespace browser_sync | 116 } // namespace syncer |
OLD | NEW |