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/file_system_usage_cache.h" | 5 #include "webkit/fileapi/file_system_usage_cache.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 | 14 |
15 namespace fileapi { | 15 namespace fileapi { |
16 | 16 |
17 namespace { | 17 namespace { |
18 const int64 kCloseDelaySeconds = 5; | 18 const int64 kCloseDelaySeconds = 5; |
19 const size_t kMaxHandleCacheSize = 2; | 19 const size_t kMaxHandleCacheSize = 2; |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 FileSystemUsageCache::FileSystemUsageCache( | 22 FileSystemUsageCache::FileSystemUsageCache( |
23 base::SequencedTaskRunner* task_runner) | 23 base::SequencedTaskRunner* task_runner) |
24 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 24 : weak_factory_(this), |
25 task_runner_(task_runner) { | 25 task_runner_(task_runner) { |
26 } | 26 } |
27 | 27 |
28 FileSystemUsageCache::~FileSystemUsageCache() { | 28 FileSystemUsageCache::~FileSystemUsageCache() { |
29 task_runner_ = NULL; | 29 task_runner_ = NULL; |
30 CloseCacheFiles(); | 30 CloseCacheFiles(); |
31 } | 31 } |
32 | 32 |
33 const base::FilePath::CharType FileSystemUsageCache::kUsageFileName[] = | 33 const base::FilePath::CharType FileSystemUsageCache::kUsageFileName[] = |
34 FILE_PATH_LITERAL(".usage"); | 34 FILE_PATH_LITERAL(".usage"); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 return !task_runner_ || task_runner_->RunsTasksOnCurrentThread(); | 302 return !task_runner_ || task_runner_->RunsTasksOnCurrentThread(); |
303 } | 303 } |
304 | 304 |
305 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { | 305 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { |
306 DCHECK(CalledOnValidThread()); | 306 DCHECK(CalledOnValidThread()); |
307 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); | 307 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); |
308 return ContainsKey(cache_files_, file_path); | 308 return ContainsKey(cache_files_, file_path); |
309 } | 309 } |
310 | 310 |
311 } // namespace fileapi | 311 } // namespace fileapi |
OLD | NEW |