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

Side by Side Diff: content/browser/background_fetch/background_fetch_job_controller.h

Issue 2860593003: Refactoring DownloadManager::DownloadURL to add proper annotation. (Closed)
Patch Set: Comment addressed. Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "content/browser/background_fetch/background_fetch_registration_id.h" 15 #include "content/browser/background_fetch/background_fetch_registration_id.h"
16 #include "content/browser/background_fetch/background_fetch_request_info.h" 16 #include "content/browser/background_fetch/background_fetch_request_info.h"
17 #include "content/common/background_fetch/background_fetch_types.h" 17 #include "content/common/background_fetch/background_fetch_types.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "net/traffic_annotation/network_traffic_annotation.h"
20 21
21 namespace net { 22 namespace net {
22 class URLRequestContextGetter; 23 class URLRequestContextGetter;
23 } 24 }
24 25
25 namespace content { 26 namespace content {
26 27
27 class BackgroundFetchDataManager; 28 class BackgroundFetchDataManager;
28 class BrowserContext; 29 class BrowserContext;
29 30
(...skipping 12 matching lines...) Expand all
42 const BackgroundFetchOptions& options, 43 const BackgroundFetchOptions& options,
43 BackgroundFetchDataManager* data_manager, 44 BackgroundFetchDataManager* data_manager,
44 BrowserContext* browser_context, 45 BrowserContext* browser_context,
45 scoped_refptr<net::URLRequestContextGetter> request_context, 46 scoped_refptr<net::URLRequestContextGetter> request_context,
46 CompletedCallback completed_callback); 47 CompletedCallback completed_callback);
47 ~BackgroundFetchJobController(); 48 ~BackgroundFetchJobController();
48 49
49 // Starts fetching the |initial_fetches|. The controller will continue to 50 // Starts fetching the |initial_fetches|. The controller will continue to
50 // fetch new content until all requests have been handled. 51 // fetch new content until all requests have been handled.
51 void Start( 52 void Start(
52 std::vector<scoped_refptr<BackgroundFetchRequestInfo>> initial_requests); 53 std::vector<scoped_refptr<BackgroundFetchRequestInfo>> initial_requests,
54 const net::NetworkTrafficAnnotationTag& traffic_annotation);
53 55
54 // Updates the representation of this Background Fetch in the user interface 56 // Updates the representation of this Background Fetch in the user interface
55 // to match the given |title|. 57 // to match the given |title|.
56 void UpdateUI(const std::string& title); 58 void UpdateUI(const std::string& title);
57 59
58 // Immediately aborts this Background Fetch by request of the developer. 60 // Immediately aborts this Background Fetch by request of the developer.
59 void Abort(); 61 void Abort();
60 62
61 // Returns the current state of this Job Controller. 63 // Returns the current state of this Job Controller.
62 State state() const { return state_; } 64 State state() const { return state_; }
63 65
64 // Returns the registration id for which this job is fetching data. 66 // Returns the registration id for which this job is fetching data.
65 const BackgroundFetchRegistrationId& registration_id() const { 67 const BackgroundFetchRegistrationId& registration_id() const {
66 return registration_id_; 68 return registration_id_;
67 } 69 }
68 70
69 // Returns the options with which this job is fetching data. 71 // Returns the options with which this job is fetching data.
70 const BackgroundFetchOptions& options() const { return options_; } 72 const BackgroundFetchOptions& options() const { return options_; }
71 73
72 private: 74 private:
73 class Core; 75 class Core;
74 76
75 // Requests the download manager to start fetching |request|. 77 // Requests the download manager to start fetching |request|.
76 void StartRequest(scoped_refptr<BackgroundFetchRequestInfo> request); 78 void StartRequest(scoped_refptr<BackgroundFetchRequestInfo> request,
79 const net::NetworkTrafficAnnotationTag& traffic_annotation);
77 80
78 // Called when the given |request| has started fetching, after having been 81 // Called when the given |request| has started fetching, after having been
79 // assigned the |download_guid| by the download system. 82 // assigned the |download_guid| by the download system.
80 void DidStartRequest(scoped_refptr<BackgroundFetchRequestInfo> request, 83 void DidStartRequest(scoped_refptr<BackgroundFetchRequestInfo> request,
81 const std::string& download_guid); 84 const std::string& download_guid);
82 85
83 // Called when the given |request| has been completed. 86 // Called when the given |request| has been completed.
84 void DidCompleteRequest(scoped_refptr<BackgroundFetchRequestInfo> request); 87 void DidCompleteRequest(scoped_refptr<BackgroundFetchRequestInfo> request);
85 88
86 // Called when a completed download has been marked as such in the DataManager 89 // Called when a completed download has been marked as such in the DataManager
(...skipping 24 matching lines...) Expand all
111 CompletedCallback completed_callback_; 114 CompletedCallback completed_callback_;
112 115
113 base::WeakPtrFactory<BackgroundFetchJobController> weak_ptr_factory_; 116 base::WeakPtrFactory<BackgroundFetchJobController> weak_ptr_factory_;
114 117
115 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobController); 118 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobController);
116 }; 119 };
117 120
118 } // namespace content 121 } // namespace content
119 122
120 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ 123 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698