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

Side by Side Diff: content/browser/service_worker/service_worker_write_to_cache_job.h

Issue 1439953006: Reland: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address David's comment Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 UpdateBefore24Hours); 57 UpdateBefore24Hours);
58 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, 58 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest,
59 UpdateAfter24Hours); 59 UpdateAfter24Hours);
60 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, 60 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest,
61 UpdateForceBypassCache); 61 UpdateForceBypassCache);
62 62
63 ~ServiceWorkerWriteToCacheJob() override; 63 ~ServiceWorkerWriteToCacheJob() override;
64 64
65 // net::URLRequestJob overrides 65 // net::URLRequestJob overrides
66 void Start() override; 66 void Start() override;
67 void StartAsync();
67 void Kill() override; 68 void Kill() override;
68 net::LoadState GetLoadState() const override; 69 net::LoadState GetLoadState() const override;
69 bool GetCharset(std::string* charset) override; 70 bool GetCharset(std::string* charset) override;
70 bool GetMimeType(std::string* mime_type) const override; 71 bool GetMimeType(std::string* mime_type) const override;
71 void GetResponseInfo(net::HttpResponseInfo* info) override; 72 void GetResponseInfo(net::HttpResponseInfo* info) override;
72 int GetResponseCode() const override; 73 int GetResponseCode() const override;
73 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; 74 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override;
74 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override; 75 int ReadRawData(net::IOBuffer* buf, int buf_size) override;
75 76
76 const net::HttpResponseInfo* http_info() const; 77 const net::HttpResponseInfo* http_info() const;
77 78
78 // Methods to drive the net request forward and 79 // Methods to drive the net request forward and
79 // write data to the disk cache. 80 // write data to the disk cache.
80 void InitNetRequest(int extra_load_flags); 81 void InitNetRequest(int extra_load_flags);
81 void StartNetRequest(); 82 void StartNetRequest();
82 net::URLRequestStatus ReadNetData(net::IOBuffer* buf, 83 net::URLRequestStatus ReadNetData(net::IOBuffer* buf,
83 int buf_size, 84 int buf_size,
84 int* bytes_read); 85 int* bytes_read);
(...skipping 17 matching lines...) Expand all
102 void OnSSLCertificateError(net::URLRequest* request, 103 void OnSSLCertificateError(net::URLRequest* request,
103 const net::SSLInfo& ssl_info, 104 const net::SSLInfo& ssl_info,
104 bool fatal) override; 105 bool fatal) override;
105 void OnBeforeNetworkStart(net::URLRequest* request, bool* defer) override; 106 void OnBeforeNetworkStart(net::URLRequest* request, bool* defer) override;
106 void OnResponseStarted(net::URLRequest* request) override; 107 void OnResponseStarted(net::URLRequest* request) override;
107 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; 108 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
108 109
109 bool CheckPathRestriction(net::URLRequest* request); 110 bool CheckPathRestriction(net::URLRequest* request);
110 111
111 // Writes network data back to the script cache if needed, and notifies the 112 // Writes network data back to the script cache if needed, and notifies the
112 // script cache of fetch completion at EOF. This function might need to do 113 // script cache of fetch completion at EOF. This function returns
113 // asynchronous IO; if so, it signals this through setting the URLRequestJob's 114 // net::IO_PENDING if the IO is to be completed asynchronously, returns a
114 // status to IO_PENDING. After this function returns, if the URLRequestJob 115 // negative number that represents a corresponding net error code (other than
115 // isn't IO_PENDING, all of the data in |io_buffer_| has been written back to 116 // net::IO_PENDING) if an error occurred, or returns a non-negative number
116 // the script cache if necessary. 117 // that represents the number of network bytes read. If the return value is
117 void HandleNetData(int bytes_read); 118 // non-negative, all of the data in |io_buffer_| has been written back to the
119 // script cache if necessary.
120 int HandleNetData(int bytes_read);
118 121
119 void NotifyDoneHelper(const net::URLRequestStatus& status, 122 void NotifyStartErrorHelper(const net::URLRequestStatus& status,
120 const std::string& status_message); 123 const std::string& status_message);
121 124
122 void NotifyFinishedCaching(net::URLRequestStatus status, 125 // Returns an error code that is passed in through |status| or a new one if an
123 const std::string& status_message); 126 // additional error is found.
127 net::Error NotifyFinishedCaching(net::URLRequestStatus status,
128 const std::string& status_message);
124 129
125 scoped_ptr<ServiceWorkerResponseReader> CreateCacheResponseReader(); 130 scoped_ptr<ServiceWorkerResponseReader> CreateCacheResponseReader();
126 scoped_ptr<ServiceWorkerResponseWriter> CreateCacheResponseWriter(); 131 scoped_ptr<ServiceWorkerResponseWriter> CreateCacheResponseWriter();
127 132
128 ResourceType resource_type_; // Differentiate main script and imports 133 ResourceType resource_type_; // Differentiate main script and imports
129 scoped_refptr<net::IOBuffer> io_buffer_; 134 scoped_refptr<net::IOBuffer> io_buffer_;
130 int io_buffer_bytes_; 135 int io_buffer_bytes_;
131 base::WeakPtr<ServiceWorkerContextCore> context_; 136 base::WeakPtr<ServiceWorkerContextCore> context_;
132 GURL url_; 137 GURL url_;
133 int64 resource_id_; 138 int64 resource_id_;
134 int64 incumbent_resource_id_; 139 int64 incumbent_resource_id_;
135 scoped_ptr<net::URLRequest> net_request_; 140 scoped_ptr<net::URLRequest> net_request_;
136 scoped_ptr<net::HttpResponseInfo> http_info_; 141 scoped_ptr<net::HttpResponseInfo> http_info_;
137 scoped_ptr<ServiceWorkerResponseWriter> writer_; 142 scoped_ptr<ServiceWorkerResponseWriter> writer_;
138 scoped_refptr<ServiceWorkerVersion> version_; 143 scoped_refptr<ServiceWorkerVersion> version_;
139 scoped_ptr<ServiceWorkerCacheWriter> cache_writer_; 144 scoped_ptr<ServiceWorkerCacheWriter> cache_writer_;
140 bool has_been_killed_; 145 bool has_been_killed_;
141 bool did_notify_started_; 146 bool did_notify_started_;
142 bool did_notify_finished_; 147 bool did_notify_finished_;
148
143 base::WeakPtrFactory<ServiceWorkerWriteToCacheJob> weak_factory_; 149 base::WeakPtrFactory<ServiceWorkerWriteToCacheJob> weak_factory_;
144 150
145 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerWriteToCacheJob); 151 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerWriteToCacheJob);
146 }; 152 };
147 153
148 } // namespace content 154 } // namespace content
149 155
150 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_ 156 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698