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/html5fs/html5_fs.h" | 5 #include "nacl_io/html5fs/html5_fs.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 return hash; | 39 return hash; |
40 } | 40 } |
41 | 41 |
42 ino_t Html5Fs::HashPath(const Path& path) { | 42 ino_t Html5Fs::HashPath(const Path& path) { |
43 // Prime the DJB2a hash | 43 // Prime the DJB2a hash |
44 ino_t hash = 5381; | 44 ino_t hash = 5381; |
45 | 45 |
46 // Apply a running DJB2a to each part of the path | 46 // Apply a running DJB2a to each part of the path |
47 for (size_t segment = 0; segment < path.Size(); segment++) { | 47 for (size_t segment = 0; segment < path.Size(); segment++) { |
48 const char *ptr = path.Part(segment).c_str(); | 48 const std::string& part = path.Part(segment); |
49 size_t len = path.Part(segment).length(); | 49 hash = HashPathSegment(hash, part.c_str(), part.length()); |
50 hash = HashPathSegment(hash, ptr, len); | |
51 } | 50 } |
52 return hash; | 51 return hash; |
53 } | 52 } |
54 | 53 |
55 | 54 |
56 // For HTML5, the INO should be the one used by the system, however PPAPI | 55 // For HTML5, the INO should be the one used by the system, however PPAPI |
57 // does not provide access to the real INO. Instead, since HTML5 does not | 56 // does not provide access to the real INO. Instead, since HTML5 does not |
58 // suport links, we assume that files are unique based on path to the base | 57 // suport links, we assume that files are unique based on path to the base |
59 // of the mount. | 58 // of the mount. |
60 void Html5Fs::OnNodeCreated(Node* node) { | 59 void Html5Fs::OnNodeCreated(Node* node) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 338 } |
340 | 339 |
341 void Html5Fs::FilesystemOpenCallback(int32_t result) { | 340 void Html5Fs::FilesystemOpenCallback(int32_t result) { |
342 AUTO_LOCK(filesysem_open_lock_); | 341 AUTO_LOCK(filesysem_open_lock_); |
343 filesystem_open_has_result_ = true; | 342 filesystem_open_has_result_ = true; |
344 filesystem_open_error_ = PPErrorToErrno(result); | 343 filesystem_open_error_ = PPErrorToErrno(result); |
345 pthread_cond_signal(&filesystem_open_cond_); | 344 pthread_cond_signal(&filesystem_open_cond_); |
346 } | 345 } |
347 | 346 |
348 } // namespace nacl_io | 347 } // namespace nacl_io |
OLD | NEW |