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

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

Issue 2902653002: Get main frame and subframe AppCache loads to work. (Closed)
Patch Set: Address review comments 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
« no previous file with comments | « no previous file | content/browser/appcache/appcache_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 17 matching lines...) Expand all
28 class AppCacheURLLoaderJob; 28 class AppCacheURLLoaderJob;
29 class URLRequestJob; 29 class URLRequestJob;
30 30
31 // Interface for an AppCache job. This is used to send data stored in the 31 // Interface for an AppCache job. This is used to send data stored in the
32 // AppCache to networking consumers. 32 // AppCache to networking consumers.
33 // Subclasses implement this interface to wrap custom job objects like 33 // Subclasses implement this interface to wrap custom job objects like
34 // URLRequestJob, URLLoaderJob, etc to ensure that these dependencies stay out 34 // URLRequestJob, URLLoaderJob, etc to ensure that these dependencies stay out
35 // of the AppCache code. 35 // of the AppCache code.
36 class CONTENT_EXPORT AppCacheJob : public base::SupportsWeakPtr<AppCacheJob> { 36 class CONTENT_EXPORT AppCacheJob : public base::SupportsWeakPtr<AppCacheJob> {
37 public: 37 public:
38 enum DeliveryType {
39 AWAITING_DELIVERY_ORDERS,
40 APPCACHED_DELIVERY,
41 NETWORK_DELIVERY,
42 ERROR_DELIVERY
43 };
44
38 // Callback that will be invoked before the request is restarted. The caller 45 // Callback that will be invoked before the request is restarted. The caller
39 // can use this opportunity to grab state from the job to determine how it 46 // can use this opportunity to grab state from the job to determine how it
40 // should behave when the request is restarted. 47 // should behave when the request is restarted.
41 // TODO(ananta) 48 // TODO(ananta)
42 // This applies only to the URLRequestJob at the moment. Look into taking 49 // This applies only to the URLRequestJob at the moment. Look into taking
43 // this knowledge out of this class. 50 // this knowledge out of this class.
44 using OnPrepareToRestartCallback = base::Closure; 51 using OnPrepareToRestartCallback = base::Closure;
45 52
46 // Factory function to create the AppCacheJob instance for the |request| 53 // Factory function to create the AppCacheJob instance for the |request|
47 // passed in. The |job_type| parameter controls the type of job which is 54 // passed in. The |job_type| parameter controls the type of job which is
48 // created. 55 // created.
49 static std::unique_ptr<AppCacheJob> Create( 56 static std::unique_ptr<AppCacheJob> Create(
50 bool is_main_resource, 57 bool is_main_resource,
51 AppCacheHost* host, 58 AppCacheHost* host,
52 AppCacheStorage* storage, 59 AppCacheStorage* storage,
53 AppCacheRequest* request, 60 AppCacheRequest* request,
54 net::NetworkDelegate* network_delegate, 61 net::NetworkDelegate* network_delegate,
55 const OnPrepareToRestartCallback& restart_callback); 62 const OnPrepareToRestartCallback& restart_callback);
56 63
57 virtual ~AppCacheJob(); 64 virtual ~AppCacheJob();
58 65
59 // Kills the job. 66 // Kills the job.
60 virtual void Kill() = 0; 67 virtual void Kill() = 0;
61 68
62 // Returns true if the job was started. 69 // Returns true if the job was started.
63 virtual bool IsStarted() const = 0; 70 virtual bool IsStarted() const = 0;
64 71
65 // Returns true if the job is waiting for instructions. 72 // Returns true if the job is waiting for instructions.
66 virtual bool IsWaiting() const = 0; 73 virtual bool IsWaiting() const;
67 74
68 // Returns true if the job is delivering a response from the cache. 75 // Returns true if the job is delivering a response from the cache.
69 virtual bool IsDeliveringAppCacheResponse() const = 0; 76 virtual bool IsDeliveringAppCacheResponse() const;
70 77
71 // Returns true if the job is delivering a response from the network. 78 // Returns true if the job is delivering a response from the network.
72 virtual bool IsDeliveringNetworkResponse() const = 0; 79 virtual bool IsDeliveringNetworkResponse() const;
73 80
74 // Returns true if the job is delivering an error response. 81 // Returns true if the job is delivering an error response.
75 virtual bool IsDeliveringErrorResponse() const = 0; 82 virtual bool IsDeliveringErrorResponse() const;
76 83
77 // Returns true if the cache entry was not found in the cache. 84 // Returns true if the cache entry was not found in the cache.
78 virtual bool IsCacheEntryNotFound() const = 0; 85 virtual bool IsCacheEntryNotFound() const;
79 86
80 // Informs the job of what response it should deliver. Only one of these 87 // Informs the job of what response it should deliver. Only one of these
81 // methods should be called, and only once per job. A job will sit idle and 88 // methods should be called, and only once per job. A job will sit idle and
82 // wait indefinitely until one of the deliver methods is called. 89 // wait indefinitely until one of the deliver methods is called.
83 virtual void DeliverAppCachedResponse(const GURL& manifest_url, 90 virtual void DeliverAppCachedResponse(const GURL& manifest_url,
84 int64_t cache_id, 91 int64_t cache_id,
85 const AppCacheEntry& entry, 92 const AppCacheEntry& entry,
86 bool is_fallback) = 0; 93 bool is_fallback) = 0;
87 94
88 // Informs the job that it should deliver the response from the network. This 95 // Informs the job that it should deliver the response from the network. This
(...skipping 15 matching lines...) Expand all
104 111
105 // Returns the underlying ApppCacheURLLoaderJob if any. This only applies to 112 // Returns the underlying ApppCacheURLLoaderJob if any. This only applies to
106 // AppCaches loaded via the URLRequest mechanism. 113 // AppCaches loaded via the URLRequest mechanism.
107 virtual AppCacheURLLoaderJob* AsURLLoaderJob(); 114 virtual AppCacheURLLoaderJob* AsURLLoaderJob();
108 115
109 protected: 116 protected:
110 AppCacheJob(); 117 AppCacheJob();
111 118
112 SEQUENCE_CHECKER(sequence_checker_); 119 SEQUENCE_CHECKER(sequence_checker_);
113 120
121 // Set to true if the AppCache entry is not found.
122 bool cache_entry_not_found_;
123
124 // The jobs delivery status.
125 DeliveryType delivery_type_;
126
114 base::WeakPtrFactory<AppCacheJob> weak_factory_; 127 base::WeakPtrFactory<AppCacheJob> weak_factory_;
115 128
116 DISALLOW_COPY_AND_ASSIGN(AppCacheJob); 129 DISALLOW_COPY_AND_ASSIGN(AppCacheJob);
117 }; 130 };
118 131
119 } // namespace content 132 } // namespace content
120 133
121 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_ 134 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_JOB_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/appcache/appcache_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698