| 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 #include "extensions/browser/extension_protocols.h" | 5 #include "extensions/browser/extension_protocols.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const base::FilePath& relative_path, | 174 const base::FilePath& relative_path, |
| 175 const std::string& content_security_policy, | 175 const std::string& content_security_policy, |
| 176 bool send_cors_header, | 176 bool send_cors_header, |
| 177 bool follow_symlinks_anywhere, | 177 bool follow_symlinks_anywhere, |
| 178 ContentVerifyJob* verify_job) | 178 ContentVerifyJob* verify_job) |
| 179 : net::URLRequestFileJob( | 179 : net::URLRequestFileJob( |
| 180 request, | 180 request, |
| 181 network_delegate, | 181 network_delegate, |
| 182 base::FilePath(), | 182 base::FilePath(), |
| 183 base::CreateTaskRunnerWithTraits( | 183 base::CreateTaskRunnerWithTraits( |
| 184 base::TaskTraits() | 184 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
| 185 .MayBlock() | 185 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})), |
| 186 .WithPriority(base::TaskPriority::BACKGROUND) | |
| 187 .WithShutdownBehavior( | |
| 188 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))), | |
| 189 verify_job_(verify_job), | 186 verify_job_(verify_job), |
| 190 seek_position_(0), | 187 seek_position_(0), |
| 191 bytes_read_(0), | 188 bytes_read_(0), |
| 192 directory_path_(directory_path), | 189 directory_path_(directory_path), |
| 193 // TODO(tc): Move all of these files into resources.pak so we don't | 190 // TODO(tc): Move all of these files into resources.pak so we don't |
| 194 // break when updating on Linux. | 191 // break when updating on Linux. |
| 195 resource_(extension_id, directory_path, relative_path), | 192 resource_(extension_id, directory_path, relative_path), |
| 196 content_security_policy_(content_security_policy), | 193 content_security_policy_(content_security_policy), |
| 197 send_cors_header_(send_cors_header), | 194 send_cors_header_(send_cors_header), |
| 198 weak_factory_(this) { | 195 weak_factory_(this) { |
| 199 if (follow_symlinks_anywhere) { | 196 if (follow_symlinks_anywhere) { |
| 200 resource_.set_follow_symlinks_anywhere(); | 197 resource_.set_follow_symlinks_anywhere(); |
| 201 } | 198 } |
| 202 } | 199 } |
| 203 | 200 |
| 204 void GetResponseInfo(net::HttpResponseInfo* info) override { | 201 void GetResponseInfo(net::HttpResponseInfo* info) override { |
| 205 *info = response_info_; | 202 *info = response_info_; |
| 206 } | 203 } |
| 207 | 204 |
| 208 void Start() override { | 205 void Start() override { |
| 209 request_timer_.reset(new base::ElapsedTimer()); | 206 request_timer_.reset(new base::ElapsedTimer()); |
| 210 base::FilePath* read_file_path = new base::FilePath; | 207 base::FilePath* read_file_path = new base::FilePath; |
| 211 base::Time* last_modified_time = new base::Time(); | 208 base::Time* last_modified_time = new base::Time(); |
| 212 | 209 |
| 213 // Inherit task priority from the calling context. | 210 // Inherit task priority from the calling context. |
| 214 base::PostTaskWithTraitsAndReply( | 211 base::PostTaskWithTraitsAndReply( |
| 215 FROM_HERE, base::TaskTraits().MayBlock(), | 212 FROM_HERE, {base::MayBlock()}, |
| 216 base::Bind(&ReadResourceFilePathAndLastModifiedTime, resource_, | 213 base::Bind(&ReadResourceFilePathAndLastModifiedTime, resource_, |
| 217 directory_path_, base::Unretained(read_file_path), | 214 directory_path_, base::Unretained(read_file_path), |
| 218 base::Unretained(last_modified_time)), | 215 base::Unretained(last_modified_time)), |
| 219 base::Bind(&URLRequestExtensionJob::OnFilePathAndLastModifiedTimeRead, | 216 base::Bind(&URLRequestExtensionJob::OnFilePathAndLastModifiedTimeRead, |
| 220 weak_factory_.GetWeakPtr(), base::Owned(read_file_path), | 217 weak_factory_.GetWeakPtr(), base::Owned(read_file_path), |
| 221 base::Owned(last_modified_time))); | 218 base::Owned(last_modified_time))); |
| 222 } | 219 } |
| 223 | 220 |
| 224 bool IsRedirectResponse(GURL* location, int* http_status_code) override { | 221 bool IsRedirectResponse(GURL* location, int* http_status_code) override { |
| 225 return false; | 222 return false; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 extensions::InfoMap* extension_info_map) { | 610 extensions::InfoMap* extension_info_map) { |
| 614 return base::MakeUnique<ExtensionProtocolHandler>(is_incognito, | 611 return base::MakeUnique<ExtensionProtocolHandler>(is_incognito, |
| 615 extension_info_map); | 612 extension_info_map); |
| 616 } | 613 } |
| 617 | 614 |
| 618 void SetExtensionProtocolTestHandler(ExtensionProtocolTestHandler* handler) { | 615 void SetExtensionProtocolTestHandler(ExtensionProtocolTestHandler* handler) { |
| 619 g_test_handler = handler; | 616 g_test_handler = handler; |
| 620 } | 617 } |
| 621 | 618 |
| 622 } // namespace extensions | 619 } // namespace extensions |
| OLD | NEW |