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

Side by Side Diff: content/browser/appcache/appcache_job.cc

Issue 2902653002: Get main frame and subframe AppCache loads to work. (Closed)
Patch Set: Add comments and helper functions 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 (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/appcache/appcache_job.h" 5 #include "content/browser/appcache/appcache_job.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/appcache/appcache_request.h" 8 #include "content/browser/appcache/appcache_request.h"
9 #include "content/browser/appcache/appcache_url_loader_job.h" 9 #include "content/browser/appcache/appcache_url_loader_job.h"
10 #include "content/browser/appcache/appcache_url_request_job.h" 10 #include "content/browser/appcache/appcache_url_request_job.h"
11 11
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 std::unique_ptr<AppCacheJob> AppCacheJob::Create( 16 std::unique_ptr<AppCacheJob> AppCacheJob::Create(
17 bool is_main_resource, 17 bool is_main_resource,
18 AppCacheHost* host, 18 AppCacheHost* host,
19 AppCacheStorage* storage, 19 AppCacheStorage* storage,
20 AppCacheRequest* request, 20 AppCacheRequest* request,
21 net::NetworkDelegate* network_delegate, 21 net::NetworkDelegate* network_delegate,
22 const OnPrepareToRestartCallback& restart_callback) { 22 const OnPrepareToRestartCallback& restart_callback) {
23 std::unique_ptr<AppCacheJob> job; 23 std::unique_ptr<AppCacheJob> job;
24 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 24 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
25 switches::kEnableNetworkService)) { 25 switches::kEnableNetworkService)) {
26 job.reset(new AppCacheURLLoaderJob); 26 job.reset(
27 new AppCacheURLLoaderJob(*(request->GetResourceRequest()), storage));
27 } else { 28 } else {
28 job.reset(new AppCacheURLRequestJob(request->GetURLRequest(), 29 job.reset(new AppCacheURLRequestJob(request->GetURLRequest(),
29 network_delegate, storage, host, 30 network_delegate, storage, host,
30 is_main_resource, restart_callback)); 31 is_main_resource, restart_callback));
31 } 32 }
32 return job; 33 return job;
33 } 34 }
34 35
35 AppCacheJob::~AppCacheJob() {} 36 AppCacheJob::~AppCacheJob() {}
36 37
38 bool AppCacheJob::IsWaiting() const {
39 return delivery_type_ == AWAITING_DELIVERY_ORDERS;
40 }
41
42 bool AppCacheJob::IsDeliveringAppCacheResponse() const {
43 return delivery_type_ == APPCACHED_DELIVERY;
44 }
45
46 bool AppCacheJob::IsDeliveringNetworkResponse() const {
47 return delivery_type_ == NETWORK_DELIVERY;
48 }
49
50 bool AppCacheJob::IsDeliveringErrorResponse() const {
51 return delivery_type_ == ERROR_DELIVERY;
52 }
53
54 bool AppCacheJob::IsCacheEntryNotFound() const {
55 return cache_entry_not_found_;
56 }
57
37 base::WeakPtr<AppCacheJob> AppCacheJob::GetWeakPtr() { 58 base::WeakPtr<AppCacheJob> AppCacheJob::GetWeakPtr() {
38 return weak_factory_.GetWeakPtr(); 59 return weak_factory_.GetWeakPtr();
39 } 60 }
40 61
41 net::URLRequestJob* AppCacheJob::AsURLRequestJob() { 62 net::URLRequestJob* AppCacheJob::AsURLRequestJob() {
42 return nullptr; 63 return nullptr;
43 } 64 }
44 65
45 AppCacheURLLoaderJob* AppCacheJob::AsURLLoaderJob() { 66 AppCacheURLLoaderJob* AppCacheJob::AsURLLoaderJob() {
46 return nullptr; 67 return nullptr;
47 } 68 }
48 69
49 AppCacheJob::AppCacheJob() : weak_factory_(this) {} 70 AppCacheJob::AppCacheJob()
71 : cache_entry_not_found_(false),
72 delivery_type_(AWAITING_DELIVERY_ORDERS),
73 weak_factory_(this) {}
50 74
51 } // namespace content 75 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698