| 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 "components/nacl/renderer/manifest_downloader.h" | 5 #include "components/nacl/renderer/manifest_downloader.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "components/nacl/renderer/histogram.h" | 8 #include "components/nacl/renderer/histogram.h" |
| 9 #include "components/nacl/renderer/nexe_load_manager.h" | 9 #include "components/nacl/renderer/nexe_load_manager.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "third_party/WebKit/public/platform/WebURLError.h" | 11 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 12 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 12 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
| 13 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 13 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 14 | 14 |
| 15 namespace nacl { | 15 namespace nacl { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 // This is a pretty arbitrary limit on the byte size of the NaCl manifest file. | 18 // This is a pretty arbitrary limit on the byte size of the NaCl manifest file. |
| 19 // Note that the resulting string object has to have at least one byte extra | 19 // Note that the resulting string object has to have at least one byte extra |
| 20 // for the null termination character. | 20 // for the null termination character. |
| 21 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; | 21 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 ManifestDownloader::ManifestDownloader( | 24 ManifestDownloader::ManifestDownloader( |
| 25 scoped_ptr<blink::WebURLLoader> url_loader, |
| 25 bool is_installed, | 26 bool is_installed, |
| 26 ManifestDownloaderCallback cb) | 27 Callback cb) |
| 27 : is_installed_(is_installed), | 28 : url_loader_(url_loader.Pass()), |
| 29 is_installed_(is_installed), |
| 28 cb_(cb), | 30 cb_(cb), |
| 29 status_code_(-1), | 31 status_code_(-1), |
| 30 pp_nacl_error_(PP_NACL_ERROR_LOAD_SUCCESS) { | 32 pp_nacl_error_(PP_NACL_ERROR_LOAD_SUCCESS) { |
| 31 CHECK(!cb.is_null()); | 33 CHECK(!cb.is_null()); |
| 32 } | 34 } |
| 33 | 35 |
| 34 ManifestDownloader::~ManifestDownloader() { | 36 ManifestDownloader::~ManifestDownloader() { } |
| 37 |
| 38 void ManifestDownloader::Load(const blink::WebURLRequest& request) { |
| 39 url_loader_->loadAsynchronously(request, this); |
| 35 } | 40 } |
| 36 | 41 |
| 37 void ManifestDownloader::didReceiveResponse( | 42 void ManifestDownloader::didReceiveResponse( |
| 38 blink::WebURLLoader* loader, | 43 blink::WebURLLoader* loader, |
| 39 const blink::WebURLResponse& response) { | 44 const blink::WebURLResponse& response) { |
| 40 if (response.httpStatusCode() != 200) | 45 if (response.httpStatusCode() != 200) |
| 41 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_LOAD_URL; | 46 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_LOAD_URL; |
| 42 status_code_ = response.httpStatusCode(); | 47 status_code_ = response.httpStatusCode(); |
| 43 } | 48 } |
| 44 | 49 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; | 88 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; |
| 84 break; | 89 break; |
| 85 } | 90 } |
| 86 } else { | 91 } else { |
| 87 // It's a WebKit error. | 92 // It's a WebKit error. |
| 88 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; | 93 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; |
| 89 } | 94 } |
| 90 } | 95 } |
| 91 | 96 |
| 92 } // namespace nacl | 97 } // namespace nacl |
| OLD | NEW |