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

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

Issue 2806713002: Some minor fixes for Background Fetch (Closed)
Patch Set: Created 3 years, 8 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_data_manager.h" 5 #include "content/browser/background_fetch/background_fetch_data_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "content/browser/background_fetch/background_fetch_constants.h" 11 #include "content/browser/background_fetch/background_fetch_constants.h"
12 #include "content/browser/background_fetch/background_fetch_context.h" 12 #include "content/browser/background_fetch/background_fetch_context.h"
13 #include "content/browser/background_fetch/background_fetch_request_info.h" 13 #include "content/browser/background_fetch/background_fetch_request_info.h"
14 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 14 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
15 #include "content/public/browser/blob_handle.h" 15 #include "content/public/browser/blob_handle.h"
16 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/download_interrupt_reasons.h" 17 #include "content/public/browser/download_interrupt_reasons.h"
18 #include "content/public/browser/download_item.h" 18 #include "content/public/browser/download_item.h"
19 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerResponseType.h"
19 20
20 namespace content { 21 namespace content {
21 22
22 // The Registration Data class encapsulates the data stored for a particular 23 // The Registration Data class encapsulates the data stored for a particular
23 // Background Fetch registration. This roughly matches the on-disk format that 24 // Background Fetch registration. This roughly matches the on-disk format that
24 // will be adhered to in the future. 25 // will be adhered to in the future.
25 class BackgroundFetchDataManager::RegistrationData { 26 class BackgroundFetchDataManager::RegistrationData {
26 public: 27 public:
27 RegistrationData(const std::vector<ServiceWorkerFetchRequest>& requests, 28 RegistrationData(const std::vector<ServiceWorkerFetchRequest>& requests,
28 const BackgroundFetchOptions& options) 29 const BackgroundFetchOptions& options)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 202
202 std::vector<std::unique_ptr<BlobHandle>> blob_handles; 203 std::vector<std::unique_ptr<BlobHandle>> blob_handles;
203 204
204 for (const auto& request : requests) { 205 for (const auto& request : requests) {
205 BackgroundFetchSettledFetch settled_fetch; 206 BackgroundFetchSettledFetch settled_fetch;
206 settled_fetch.request = request->fetch_request(); 207 settled_fetch.request = request->fetch_request();
207 208
208 settled_fetch.response.url_list = request->GetURLChain(); 209 settled_fetch.response.url_list = request->GetURLChain();
209 // TODO: settled_fetch.response.status_code 210 // TODO: settled_fetch.response.status_code
210 // TODO: settled_fetch.response.status_text 211 // TODO: settled_fetch.response.status_text
211 // TODO: settled_fetch.response.response_type 212 settled_fetch.response.response_type =
213 blink::WebServiceWorkerResponseTypeDefault;
212 // TODO: settled_fetch.response.headers 214 // TODO: settled_fetch.response.headers
213 215
214 if (request->GetFileSize() > 0) { 216 if (request->GetFileSize() > 0) {
215 DCHECK(!request->GetFilePath().empty()); 217 DCHECK(!request->GetFilePath().empty());
216 218
217 std::unique_ptr<BlobHandle> blob_handle = 219 std::unique_ptr<BlobHandle> blob_handle =
218 blob_storage_context_->CreateFileBackedBlob( 220 blob_storage_context_->CreateFileBackedBlob(
219 request->GetFilePath(), 0 /* offset */, request->GetFileSize(), 221 request->GetFilePath(), 0 /* offset */, request->GetFileSize(),
220 base::Time() /* expected_modification_time */); 222 base::Time() /* expected_modification_time */);
221 223
(...skipping 25 matching lines...) Expand all
247 std::move(callback).Run(blink::mojom::BackgroundFetchError::INVALID_TAG); 249 std::move(callback).Run(blink::mojom::BackgroundFetchError::INVALID_TAG);
248 return; 250 return;
249 } 251 }
250 252
251 registrations_.erase(iter); 253 registrations_.erase(iter);
252 254
253 std::move(callback).Run(blink::mojom::BackgroundFetchError::NONE); 255 std::move(callback).Run(blink::mojom::BackgroundFetchError::NONE);
254 } 256 }
255 257
256 } // namespace content 258 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698