OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_SAFE_BROWSING_TWO_PHASE_UPLOADER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_TWO_PHASE_UPLOADER_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_TWO_PHASE_UPLOADER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_TWO_PHASE_UPLOADER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "net/traffic_annotation/network_traffic_annotation.h" |
15 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class TaskRunner; | 20 class TaskRunner; |
20 } | 21 } |
21 namespace net { | 22 namespace net { |
22 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
23 } | 24 } |
24 | 25 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // response_data will specify information about the error. |finish_callback| | 63 // response_data will specify information about the error. |finish_callback| |
63 // will not be called if the upload is cancelled by destructing the | 64 // will not be called if the upload is cancelled by destructing the |
64 // TwoPhaseUploader object before completion. | 65 // TwoPhaseUploader object before completion. |
65 static std::unique_ptr<TwoPhaseUploader> Create( | 66 static std::unique_ptr<TwoPhaseUploader> Create( |
66 net::URLRequestContextGetter* url_request_context_getter, | 67 net::URLRequestContextGetter* url_request_context_getter, |
67 base::TaskRunner* file_task_runner, | 68 base::TaskRunner* file_task_runner, |
68 const GURL& base_url, | 69 const GURL& base_url, |
69 const std::string& metadata, | 70 const std::string& metadata, |
70 const base::FilePath& file_path, | 71 const base::FilePath& file_path, |
71 const ProgressCallback& progress_callback, | 72 const ProgressCallback& progress_callback, |
72 const FinishCallback& finish_callback); | 73 const FinishCallback& finish_callback, |
| 74 const net::NetworkTrafficAnnotationTag& traffic_annotation); |
73 | 75 |
74 // Makes the passed |factory| the factory used to instantiate | 76 // Makes the passed |factory| the factory used to instantiate |
75 // a TwoPhaseUploader. Useful for tests. | 77 // a TwoPhaseUploader. Useful for tests. |
76 static void RegisterFactory(TwoPhaseUploaderFactory* factory) { | 78 static void RegisterFactory(TwoPhaseUploaderFactory* factory) { |
77 factory_ = factory; | 79 factory_ = factory; |
78 } | 80 } |
79 | 81 |
80 // Begins the upload process. | 82 // Begins the upload process. |
81 virtual void Start() = 0; | 83 virtual void Start() = 0; |
82 | 84 |
83 private: | 85 private: |
84 // The factory that controls the creation of SafeBrowsingProtocolManager. | 86 // The factory that controls the creation of SafeBrowsingProtocolManager. |
85 // This is used by tests. | 87 // This is used by tests. |
86 static TwoPhaseUploaderFactory* factory_; | 88 static TwoPhaseUploaderFactory* factory_; |
87 }; | 89 }; |
88 | 90 |
89 class TwoPhaseUploaderFactory { | 91 class TwoPhaseUploaderFactory { |
90 public: | 92 public: |
91 virtual ~TwoPhaseUploaderFactory() {} | 93 virtual ~TwoPhaseUploaderFactory() {} |
92 | 94 |
93 virtual std::unique_ptr<TwoPhaseUploader> CreateTwoPhaseUploader( | 95 virtual std::unique_ptr<TwoPhaseUploader> CreateTwoPhaseUploader( |
94 net::URLRequestContextGetter* url_request_context_getter, | 96 net::URLRequestContextGetter* url_request_context_getter, |
95 base::TaskRunner* file_task_runner, | 97 base::TaskRunner* file_task_runner, |
96 const GURL& base_url, | 98 const GURL& base_url, |
97 const std::string& metadata, | 99 const std::string& metadata, |
98 const base::FilePath& file_path, | 100 const base::FilePath& file_path, |
99 const TwoPhaseUploader::ProgressCallback& progress_callback, | 101 const TwoPhaseUploader::ProgressCallback& progress_callback, |
100 const TwoPhaseUploader::FinishCallback& finish_callback) = 0; | 102 const TwoPhaseUploader::FinishCallback& finish_callback, |
| 103 const net::NetworkTrafficAnnotationTag& traffic_annotation) = 0; |
101 }; | 104 }; |
102 | 105 |
103 #endif // CHROME_BROWSER_SAFE_BROWSING_TWO_PHASE_UPLOADER_H_ | 106 #endif // CHROME_BROWSER_SAFE_BROWSING_TWO_PHASE_UPLOADER_H_ |
OLD | NEW |