| OLD | NEW |
| 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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 47 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
| 48 UpdateBefore24Hours); | 48 UpdateBefore24Hours); |
| 49 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 49 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
| 50 UpdateAfter24Hours); | 50 UpdateAfter24Hours); |
| 51 | 51 |
| 52 virtual ~ServiceWorkerWriteToCacheJob(); | 52 virtual ~ServiceWorkerWriteToCacheJob(); |
| 53 | 53 |
| 54 // net::URLRequestJob overrides | 54 // net::URLRequestJob overrides |
| 55 virtual void Start() OVERRIDE; | 55 virtual void Start() override; |
| 56 virtual void Kill() OVERRIDE; | 56 virtual void Kill() override; |
| 57 virtual net::LoadState GetLoadState() const OVERRIDE; | 57 virtual net::LoadState GetLoadState() const override; |
| 58 virtual bool GetCharset(std::string* charset) OVERRIDE; | 58 virtual bool GetCharset(std::string* charset) override; |
| 59 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 59 virtual bool GetMimeType(std::string* mime_type) const override; |
| 60 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; | 60 virtual void GetResponseInfo(net::HttpResponseInfo* info) override; |
| 61 virtual int GetResponseCode() const OVERRIDE; | 61 virtual int GetResponseCode() const override; |
| 62 virtual void SetExtraRequestHeaders( | 62 virtual void SetExtraRequestHeaders( |
| 63 const net::HttpRequestHeaders& headers) OVERRIDE; | 63 const net::HttpRequestHeaders& headers) override; |
| 64 virtual bool ReadRawData(net::IOBuffer* buf, | 64 virtual bool ReadRawData(net::IOBuffer* buf, |
| 65 int buf_size, | 65 int buf_size, |
| 66 int *bytes_read) OVERRIDE; | 66 int *bytes_read) override; |
| 67 | 67 |
| 68 const net::HttpResponseInfo* http_info() const; | 68 const net::HttpResponseInfo* http_info() const; |
| 69 | 69 |
| 70 // Methods to drive the net request forward and | 70 // Methods to drive the net request forward and |
| 71 // write data to the disk cache. | 71 // write data to the disk cache. |
| 72 void InitNetRequest(int extra_load_flags); | 72 void InitNetRequest(int extra_load_flags); |
| 73 void StartNetRequest(); | 73 void StartNetRequest(); |
| 74 net::URLRequestStatus ReadNetData( | 74 net::URLRequestStatus ReadNetData( |
| 75 net::IOBuffer* buf, | 75 net::IOBuffer* buf, |
| 76 int buf_size, | 76 int buf_size, |
| 77 int *bytes_read); | 77 int *bytes_read); |
| 78 void WriteHeadersToCache(); | 78 void WriteHeadersToCache(); |
| 79 void OnWriteHeadersComplete(int result); | 79 void OnWriteHeadersComplete(int result); |
| 80 void WriteDataToCache(int bytes_to_write); | 80 void WriteDataToCache(int bytes_to_write); |
| 81 void OnWriteDataComplete(int result); | 81 void OnWriteDataComplete(int result); |
| 82 | 82 |
| 83 // net::URLRequest::Delegate overrides that observe the net request. | 83 // net::URLRequest::Delegate overrides that observe the net request. |
| 84 virtual void OnReceivedRedirect( | 84 virtual void OnReceivedRedirect( |
| 85 net::URLRequest* request, | 85 net::URLRequest* request, |
| 86 const net::RedirectInfo& redirect_info, | 86 const net::RedirectInfo& redirect_info, |
| 87 bool* defer_redirect) OVERRIDE; | 87 bool* defer_redirect) override; |
| 88 virtual void OnAuthRequired( | 88 virtual void OnAuthRequired( |
| 89 net::URLRequest* request, | 89 net::URLRequest* request, |
| 90 net::AuthChallengeInfo* auth_info) OVERRIDE; | 90 net::AuthChallengeInfo* auth_info) override; |
| 91 virtual void OnCertificateRequested( | 91 virtual void OnCertificateRequested( |
| 92 net::URLRequest* request, | 92 net::URLRequest* request, |
| 93 net::SSLCertRequestInfo* cert_request_info) OVERRIDE; | 93 net::SSLCertRequestInfo* cert_request_info) override; |
| 94 virtual void OnSSLCertificateError( | 94 virtual void OnSSLCertificateError( |
| 95 net::URLRequest* request, | 95 net::URLRequest* request, |
| 96 const net::SSLInfo& ssl_info, | 96 const net::SSLInfo& ssl_info, |
| 97 bool fatal) OVERRIDE; | 97 bool fatal) override; |
| 98 virtual void OnBeforeNetworkStart( | 98 virtual void OnBeforeNetworkStart( |
| 99 net::URLRequest* request, | 99 net::URLRequest* request, |
| 100 bool* defer) OVERRIDE; | 100 bool* defer) override; |
| 101 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; | 101 virtual void OnResponseStarted(net::URLRequest* request) override; |
| 102 virtual void OnReadCompleted( | 102 virtual void OnReadCompleted( |
| 103 net::URLRequest* request, | 103 net::URLRequest* request, |
| 104 int bytes_read) OVERRIDE; | 104 int bytes_read) override; |
| 105 | 105 |
| 106 void AsyncNotifyDoneHelper(const net::URLRequestStatus& status); | 106 void AsyncNotifyDoneHelper(const net::URLRequestStatus& status); |
| 107 | 107 |
| 108 ResourceType resource_type_; // Differentiate main script and imports | 108 ResourceType resource_type_; // Differentiate main script and imports |
| 109 scoped_refptr<net::IOBuffer> io_buffer_; | 109 scoped_refptr<net::IOBuffer> io_buffer_; |
| 110 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; | 110 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; |
| 111 base::WeakPtr<ServiceWorkerContextCore> context_; | 111 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 112 GURL url_; | 112 GURL url_; |
| 113 int64 response_id_; | 113 int64 response_id_; |
| 114 scoped_ptr<net::URLRequest> net_request_; | 114 scoped_ptr<net::URLRequest> net_request_; |
| 115 scoped_ptr<net::HttpResponseInfo> http_info_; | 115 scoped_ptr<net::HttpResponseInfo> http_info_; |
| 116 scoped_ptr<ServiceWorkerResponseWriter> writer_; | 116 scoped_ptr<ServiceWorkerResponseWriter> writer_; |
| 117 scoped_refptr<ServiceWorkerVersion> version_; | 117 scoped_refptr<ServiceWorkerVersion> version_; |
| 118 bool has_been_killed_; | 118 bool has_been_killed_; |
| 119 bool did_notify_started_; | 119 bool did_notify_started_; |
| 120 bool did_notify_finished_; | 120 bool did_notify_finished_; |
| 121 base::WeakPtrFactory<ServiceWorkerWriteToCacheJob> weak_factory_; | 121 base::WeakPtrFactory<ServiceWorkerWriteToCacheJob> weak_factory_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerWriteToCacheJob); | 123 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerWriteToCacheJob); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 } // namespace content | 126 } // namespace content |
| 127 | 127 |
| 128 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_ | 128 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_ |
| OLD | NEW |