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 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_STOPPED_REPORTER_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_STOPPED_REPORTER_H_ |
6 #define COMPONENTS_SYNC_DRIVER_SYNC_STOPPED_REPORTER_H_ | 6 #define COMPONENTS_SYNC_DRIVER_SYNC_STOPPED_REPORTER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "net/url_request/url_fetcher.h" | 14 #include "net/url_request/url_fetcher.h" |
15 #include "net/url_request/url_fetcher_delegate.h" | 15 #include "net/url_request/url_fetcher_delegate.h" |
16 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace browser_sync { | 19 namespace browser_sync { |
20 | 20 |
21 // Manages informing the sync server that sync has been disabled. | 21 // Manages informing the sync server that sync has been disabled. |
22 // An implementation of URLFetcherDelegate was needed in order to | 22 // An implementation of URLFetcherDelegate was needed in order to |
23 // clean up the fetcher_ pointer when the request completes. | 23 // clean up the fetcher_ pointer when the request completes. |
24 class SyncStoppedReporter : public net::URLFetcherDelegate { | 24 class SyncStoppedReporter : public net::URLFetcherDelegate { |
25 public: | 25 public: |
26 enum Result { | 26 enum Result { RESULT_SUCCESS, RESULT_ERROR, RESULT_TIMEOUT }; |
27 RESULT_SUCCESS, | |
28 RESULT_ERROR, | |
29 RESULT_TIMEOUT | |
30 }; | |
31 | 27 |
32 typedef base::Callback<void(const Result&)> ResultCallback; | 28 typedef base::Callback<void(const Result&)> ResultCallback; |
33 | 29 |
34 SyncStoppedReporter(const GURL& sync_service_url, | 30 SyncStoppedReporter( |
| 31 const GURL& sync_service_url, |
35 const std::string& user_agent, | 32 const std::string& user_agent, |
36 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 33 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
37 const ResultCallback& callback); | 34 const ResultCallback& callback); |
38 ~SyncStoppedReporter() override; | 35 ~SyncStoppedReporter() override; |
39 | 36 |
40 // Inform the sync server that sync was stopped on this device. | 37 // Inform the sync server that sync was stopped on this device. |
41 // |access_token|, |cache_guid|, and |birthday| must not be empty. | 38 // |access_token|, |cache_guid|, and |birthday| must not be empty. |
42 void ReportSyncStopped(const std::string& access_token, | 39 void ReportSyncStopped(const std::string& access_token, |
43 const std::string& cache_guid, | 40 const std::string& cache_guid, |
44 const std::string& birthday); | 41 const std::string& birthday); |
(...skipping 29 matching lines...) Expand all Loading... |
74 | 71 |
75 // A callback for request completion or timeout. | 72 // A callback for request completion or timeout. |
76 ResultCallback callback_; | 73 ResultCallback callback_; |
77 | 74 |
78 DISALLOW_COPY_AND_ASSIGN(SyncStoppedReporter); | 75 DISALLOW_COPY_AND_ASSIGN(SyncStoppedReporter); |
79 }; | 76 }; |
80 | 77 |
81 } // namespace browser_sync | 78 } // namespace browser_sync |
82 | 79 |
83 #endif // COMPONENTS_SYNC_DRIVER_SYNC_STOPPED_REPORTER_H_ | 80 #endif // COMPONENTS_SYNC_DRIVER_SYNC_STOPPED_REPORTER_H_ |
OLD | NEW |