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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 int encoded_data_length) { | 47 int encoded_data_length) { |
48 if (buffer_.size() + data_length > kNaClManifestMaxFileBytes) { | 48 if (buffer_.size() + data_length > kNaClManifestMaxFileBytes) { |
49 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_TOO_LARGE; | 49 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_TOO_LARGE; |
50 buffer_.clear(); | 50 buffer_.clear(); |
51 } | 51 } |
52 | 52 |
53 if (pp_nacl_error_ == PP_NACL_ERROR_LOAD_SUCCESS) | 53 if (pp_nacl_error_ == PP_NACL_ERROR_LOAD_SUCCESS) |
54 buffer_.append(data, data_length); | 54 buffer_.append(data, data_length); |
55 } | 55 } |
56 | 56 |
57 void ManifestDownloader::didFinishLoading( | 57 void ManifestDownloader::Close() { |
58 blink::WebURLLoader* loader, | |
59 double finish_time, | |
60 int64_t total_encoded_data_length) { | |
61 // We log the status code here instead of in didReceiveResponse so that we | 58 // We log the status code here instead of in didReceiveResponse so that we |
62 // always log a histogram value, even when we never receive a status code. | 59 // always log a histogram value, even when we never receive a status code. |
63 HistogramHTTPStatusCode( | 60 HistogramHTTPStatusCode( |
64 is_installed_ ? "NaCl.HttpStatusCodeClass.Manifest.InstalledApp" : | 61 is_installed_ ? "NaCl.HttpStatusCodeClass.Manifest.InstalledApp" : |
65 "NaCl.HttpStatusCodeClass.Manifest.NotInstalledApp", | 62 "NaCl.HttpStatusCodeClass.Manifest.NotInstalledApp", |
66 status_code_); | 63 status_code_); |
67 | 64 |
68 cb_.Run(pp_nacl_error_, buffer_); | 65 cb_.Run(pp_nacl_error_, buffer_); |
69 delete this; | 66 delete this; |
70 } | 67 } |
71 | 68 |
| 69 void ManifestDownloader::didFinishLoading( |
| 70 blink::WebURLLoader* loader, |
| 71 double finish_time, |
| 72 int64_t total_encoded_data_length) { |
| 73 Close(); |
| 74 } |
| 75 |
72 void ManifestDownloader::didFail( | 76 void ManifestDownloader::didFail( |
73 blink::WebURLLoader* loader, | 77 blink::WebURLLoader* loader, |
74 const blink::WebURLError& error) { | 78 const blink::WebURLError& error) { |
75 // TODO(teravest): Find a place to share this code with PepperURLLoaderHost. | 79 // TODO(teravest): Find a place to share this code with PepperURLLoaderHost. |
76 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_LOAD_URL; | 80 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_LOAD_URL; |
77 if (error.domain.equals(blink::WebString::fromUTF8(net::kErrorDomain))) { | 81 if (error.domain.equals(blink::WebString::fromUTF8(net::kErrorDomain))) { |
78 switch (error.reason) { | 82 switch (error.reason) { |
79 case net::ERR_ACCESS_DENIED: | 83 case net::ERR_ACCESS_DENIED: |
80 case net::ERR_NETWORK_ACCESS_DENIED: | 84 case net::ERR_NETWORK_ACCESS_DENIED: |
81 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; | 85 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; |
82 break; | 86 break; |
83 } | 87 } |
84 } else { | 88 } else { |
85 // It's a WebKit error. | 89 // It's a WebKit error. |
86 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; | 90 pp_nacl_error_ = PP_NACL_ERROR_MANIFEST_NOACCESS_URL; |
87 } | 91 } |
| 92 |
| 93 Close(); |
88 } | 94 } |
89 | 95 |
90 } // namespace nacl | 96 } // namespace nacl |
OLD | NEW |