OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/fileapi/isolated_context.h" | 5 #include "webkit/fileapi/isolated_context.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 | 12 |
13 namespace fileapi { | 13 namespace fileapi { |
14 | 14 |
15 static base::LazyInstance<IsolatedContext>::Leaky g_isolated_context = | 15 static base::LazyInstance<IsolatedContext>::Leaky g_isolated_context = |
16 LAZY_INSTANCE_INITIALIZER; | 16 LAZY_INSTANCE_INITIALIZER; |
17 | 17 |
18 // static | 18 // static |
19 IsolatedContext* IsolatedContext::GetInstance() { | 19 IsolatedContext* IsolatedContext::GetInstance() { |
20 return &g_isolated_context.Get(); | 20 return g_isolated_context.Pointer(); |
21 } | 21 } |
22 | 22 |
23 std::string IsolatedContext::RegisterIsolatedFileSystem( | 23 std::string IsolatedContext::RegisterIsolatedFileSystem( |
24 const std::set<FilePath>& files) { | 24 const std::set<FilePath>& files) { |
25 base::AutoLock locker(lock_); | 25 base::AutoLock locker(lock_); |
26 std::string filesystem_id = GetNewFileSystemId(); | 26 std::string filesystem_id = GetNewFileSystemId(); |
27 // Stores basename to fullpath map, as we store the basenames as | 27 // Stores basename to fullpath map, as we store the basenames as |
28 // the filesystem's toplevel entries. | 28 // the filesystem's toplevel entries. |
29 PathMap toplevels; | 29 PathMap toplevels; |
30 for (std::set<FilePath>::const_iterator iter = files.begin(); | 30 for (std::set<FilePath>::const_iterator iter = files.begin(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 uint32 random_data[4]; | 134 uint32 random_data[4]; |
135 std::string id; | 135 std::string id; |
136 do { | 136 do { |
137 base::RandBytes(random_data, sizeof(random_data)); | 137 base::RandBytes(random_data, sizeof(random_data)); |
138 id = base::HexEncode(random_data, sizeof(random_data)); | 138 id = base::HexEncode(random_data, sizeof(random_data)); |
139 } while (toplevel_map_.find(id) != toplevel_map_.end()); | 139 } while (toplevel_map_.find(id) != toplevel_map_.end()); |
140 return id; | 140 return id; |
141 } | 141 } |
142 | 142 |
143 } // namespace fileapi | 143 } // namespace fileapi |
OLD | NEW |