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

Side by Side Diff: content/browser/background_fetch/background_fetch_context.cc

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 #include "content/browser/background_fetch/background_fetch_context.h" 5 #include "content/browser/background_fetch/background_fetch_context.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "content/browser/background_fetch/background_fetch_data_manager.h" 8 #include "content/browser/background_fetch/background_fetch_data_manager.h"
9 #include "content/browser/background_fetch/background_fetch_event_dispatcher.h" 9 #include "content/browser/background_fetch/background_fetch_event_dispatcher.h"
10 #include "content/browser/background_fetch/background_fetch_job_controller.h" 10 #include "content/browser/background_fetch/background_fetch_job_controller.h"
11 #include "content/browser/background_fetch/background_fetch_registration_id.h" 11 #include "content/browser/background_fetch/background_fetch_registration_id.h"
12 #include "content/browser/service_worker/service_worker_context_wrapper.h" 12 #include "content/browser/service_worker/service_worker_context_wrapper.h"
13 #include "content/browser/storage_partition_impl.h" 13 #include "content/browser/storage_partition_impl.h"
14 #include "content/public/browser/blob_handle.h" 14 #include "content/public/browser/blob_handle.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "net/traffic_annotation/network_traffic_annotation.h"
16 #include "net/url_request/url_request_context_getter.h" 17 #include "net/url_request/url_request_context_getter.h"
17 #include "url/origin.h" 18 #include "url/origin.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 namespace { 22 namespace {
22 23
23 // Records the |error| status issued by the DataManager after it was requested 24 // Records the |error| status issued by the DataManager after it was requested
24 // to create and store a new Background Fetch registration. 25 // to create and store a new Background Fetch registration.
25 void RecordRegistrationCreatedError(blink::mojom::BackgroundFetchError error) { 26 void RecordRegistrationCreatedError(blink::mojom::BackgroundFetchError error) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 base::MakeUnique<BackgroundFetchJobController>( 152 base::MakeUnique<BackgroundFetchJobController>(
152 registration_id, options, data_manager_.get(), browser_context_, 153 registration_id, options, data_manager_.get(), browser_context_,
153 request_context_getter_, 154 request_context_getter_,
154 base::BindOnce(&BackgroundFetchContext::DidCompleteJob, this)); 155 base::BindOnce(&BackgroundFetchContext::DidCompleteJob, this));
155 156
156 // TODO(peter): We should actually be able to use Background Fetch in layout 157 // TODO(peter): We should actually be able to use Background Fetch in layout
157 // tests. That requires a download manager and a request context. 158 // tests. That requires a download manager and a request context.
158 if (request_context_getter_) { 159 if (request_context_getter_) {
159 // Start fetching the |initial_requests| immediately. At some point in the 160 // Start fetching the |initial_requests| immediately. At some point in the
160 // future we may want a more elaborate scheduling mechanism here. 161 // future we may want a more elaborate scheduling mechanism here.
161 controller->Start(std::move(initial_requests)); 162 controller->Start(std::move(initial_requests), NO_TRAFFIC_ANNOTATION_YET);
162 } 163 }
163 164
164 active_fetches_.insert( 165 active_fetches_.insert(
165 std::make_pair(registration_id, std::move(controller))); 166 std::make_pair(registration_id, std::move(controller)));
166 } 167 }
167 168
168 void BackgroundFetchContext::DidCompleteJob( 169 void BackgroundFetchContext::DidCompleteJob(
169 BackgroundFetchJobController* controller) { 170 BackgroundFetchJobController* controller) {
170 const BackgroundFetchRegistrationId& registration_id = 171 const BackgroundFetchRegistrationId& registration_id =
171 controller->registration_id(); 172 controller->registration_id();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 229
229 // Delete all persistent information associated with the |registration_id|. 230 // Delete all persistent information associated with the |registration_id|.
230 data_manager_->DeleteRegistration( 231 data_manager_->DeleteRegistration(
231 registration_id, base::BindOnce(&RecordRegistrationDeletedError)); 232 registration_id, base::BindOnce(&RecordRegistrationDeletedError));
232 233
233 // Delete the local state associated with the |registration_id|. 234 // Delete the local state associated with the |registration_id|.
234 active_fetches_.erase(registration_id); 235 active_fetches_.erase(registration_id);
235 } 236 }
236 237
237 } // namespace content 238 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698