OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "nacl_io/httpfs/http_fs.h" | 5 #include "nacl_io/httpfs/http_fs.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <ctype.h> | 8 #include <ctype.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 PP_URLREQUESTPROPERTY_HEADERS, | 193 PP_URLREQUESTPROPERTY_HEADERS, |
194 var_interface->VarFromUtf8(headers.c_str(), headers.length())); | 194 var_interface->VarFromUtf8(headers.c_str(), headers.length())); |
195 | 195 |
196 return request_info; | 196 return request_info; |
197 } | 197 } |
198 | 198 |
199 HttpFs::HttpFs() | 199 HttpFs::HttpFs() |
200 : allow_cors_(false), | 200 : allow_cors_(false), |
201 allow_credentials_(false), | 201 allow_credentials_(false), |
202 cache_stat_(true), | 202 cache_stat_(true), |
203 cache_content_(true) {} | 203 cache_content_(true) { |
| 204 } |
204 | 205 |
205 Error HttpFs::Init(const FsInitArgs& args) { | 206 Error HttpFs::Init(const FsInitArgs& args) { |
206 Error error = Filesystem::Init(args); | 207 Error error = Filesystem::Init(args); |
207 if (error) | 208 if (error) |
208 return error; | 209 return error; |
209 | 210 |
210 // Parse filesystem args. | 211 // Parse filesystem args. |
211 for (StringMap_t::const_iterator iter = args.string_map.begin(); | 212 for (StringMap_t::const_iterator iter = args.string_map.begin(); |
212 iter != args.string_map.end(); | 213 iter != args.string_map.end(); |
213 ++iter) { | 214 ++iter) { |
(...skipping 27 matching lines...) Expand all Loading... |
241 cache_content_ = iter->second == "true"; | 242 cache_content_ = iter->second == "true"; |
242 } else { | 243 } else { |
243 // Assume it is a header to pass to an HTTP request. | 244 // Assume it is a header to pass to an HTTP request. |
244 headers_[NormalizeHeaderKey(iter->first)] = iter->second; | 245 headers_[NormalizeHeaderKey(iter->first)] = iter->second; |
245 } | 246 } |
246 } | 247 } |
247 | 248 |
248 return 0; | 249 return 0; |
249 } | 250 } |
250 | 251 |
251 void HttpFs::Destroy() {} | 252 void HttpFs::Destroy() { |
| 253 } |
252 | 254 |
253 Error HttpFs::FindOrCreateDir(const Path& path, ScopedNode* out_node) { | 255 Error HttpFs::FindOrCreateDir(const Path& path, ScopedNode* out_node) { |
254 out_node->reset(NULL); | 256 out_node->reset(NULL); |
255 std::string strpath = path.Join(); | 257 std::string strpath = path.Join(); |
256 NodeMap_t::iterator iter = node_cache_.find(strpath); | 258 NodeMap_t::iterator iter = node_cache_.find(strpath); |
257 if (iter != node_cache_.end()) { | 259 if (iter != node_cache_.end()) { |
258 *out_node = iter->second; | 260 *out_node = iter->second; |
259 return 0; | 261 return 0; |
260 } | 262 } |
261 | 263 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 *out_manifest = text; | 407 *out_manifest = text; |
406 return 0; | 408 return 0; |
407 } | 409 } |
408 | 410 |
409 std::string HttpFs::MakeUrl(const Path& path) { | 411 std::string HttpFs::MakeUrl(const Path& path) { |
410 return url_root_ + | 412 return url_root_ + |
411 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join()); | 413 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join()); |
412 } | 414 } |
413 | 415 |
414 } // namespace nacl_io | 416 } // namespace nacl_io |
OLD | NEW |