Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc

Issue 547713002: [NaCl SDK] nacl_io: Always create directory node in http filesystem root. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_node.h" 5 #include "nacl_io/httpfs/http_fs_node.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 HttpFsNode::HttpFsNode(Filesystem* filesystem, 226 HttpFsNode::HttpFsNode(Filesystem* filesystem,
227 const std::string& url, 227 const std::string& url,
228 bool cache_content) 228 bool cache_content)
229 : Node(filesystem), 229 : Node(filesystem),
230 url_(url), 230 url_(url),
231 buffer_(NULL), 231 buffer_(NULL),
232 buffer_len_(0), 232 buffer_len_(0),
233 cache_content_(cache_content), 233 cache_content_(cache_content),
234 has_cached_size_(false) { 234 has_cached_size_(false) {
235 } 235 // http nodes are read-only by default
236 236 SetMode(S_IRALL);
237 void HttpFsNode::SetMode(int mode) {
238 stat_.st_mode = mode;
239 } 237 }
240 238
241 Error HttpFsNode::GetStat_Locked(struct stat* stat) { 239 Error HttpFsNode::GetStat_Locked(struct stat* stat) {
242 // Assume we need to 'HEAD' if we do not know the size, otherwise, assume 240 // Assume we need to 'HEAD' if we do not know the size, otherwise, assume
243 // that the information is constant. We can add a timeout if needed. 241 // that the information is constant. We can add a timeout if needed.
244 HttpFs* filesystem = static_cast<HttpFs*>(filesystem_); 242 HttpFs* filesystem = static_cast<HttpFs*>(filesystem_);
245 if (!has_cached_size_ || !filesystem->cache_stat_) { 243 if (!has_cached_size_ || !filesystem->cache_stat_) {
246 StringMap_t headers; 244 StringMap_t headers;
247 ScopedResource loader(filesystem_->ppapi()); 245 ScopedResource loader(filesystem_->ppapi());
248 ScopedResource request(filesystem_->ppapi()); 246 ScopedResource request(filesystem_->ppapi());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (error) 288 if (error)
291 return error; 289 return error;
292 290
293 SetCachedSize(bytes_read); 291 SetCachedSize(bytes_read);
294 } 292 }
295 293
296 stat_.st_atime = 0; // TODO(binji): Use "Last-Modified". 294 stat_.st_atime = 0; // TODO(binji): Use "Last-Modified".
297 stat_.st_mtime = 0; 295 stat_.st_mtime = 0;
298 stat_.st_ctime = 0; 296 stat_.st_ctime = 0;
299 297
300 stat_.st_mode |= S_IFREG; 298 SetType(S_IFREG);
301 } 299 }
302 300
303 // Fill the stat structure if provided 301 // Fill the stat structure if provided
304 if (stat) 302 if (stat)
305 *stat = stat_; 303 *stat = stat_;
306 304
307 return 0; 305 return 0;
308 } 306 }
309 307
310 Error HttpFsNode::OpenUrl(const char* method, 308 Error HttpFsNode::OpenUrl(const char* method,
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 assert(bytes_read <= bytes_to_read); 671 assert(bytes_read <= bytes_to_read);
674 bytes_to_read -= bytes_read; 672 bytes_to_read -= bytes_read;
675 out_buffer += bytes_read; 673 out_buffer += bytes_read;
676 } 674 }
677 675
678 *out_bytes = count; 676 *out_bytes = count;
679 return 0; 677 return 0;
680 } 678 }
681 679
682 } // namespace nacl_io 680 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.h ('k') | native_client_sdk/src/libraries/nacl_io/node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698