| 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 "content/browser/dom_storage/dom_storage_context_impl.h" | 5 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| 11 #include <utility> |
| 12 |
| 11 #include "base/bind.h" | 13 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 13 #include "base/files/file_enumerator.h" | 15 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 15 #include "base/guid.h" | 17 #include "base/guid.h" |
| 16 #include "base/location.h" | 18 #include "base/location.h" |
| 17 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 19 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 20 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 69 } |
| 68 return total_stats; | 70 return total_stats; |
| 69 } | 71 } |
| 70 | 72 |
| 71 } // namespace | 73 } // namespace |
| 72 | 74 |
| 73 DOMStorageContextImpl::DOMStorageContextImpl( | 75 DOMStorageContextImpl::DOMStorageContextImpl( |
| 74 const base::FilePath& localstorage_directory, | 76 const base::FilePath& localstorage_directory, |
| 75 const base::FilePath& sessionstorage_directory, | 77 const base::FilePath& sessionstorage_directory, |
| 76 storage::SpecialStoragePolicy* special_storage_policy, | 78 storage::SpecialStoragePolicy* special_storage_policy, |
| 77 DOMStorageTaskRunner* task_runner) | 79 scoped_refptr<DOMStorageTaskRunner> task_runner) |
| 78 : localstorage_directory_(localstorage_directory), | 80 : localstorage_directory_(localstorage_directory), |
| 79 sessionstorage_directory_(sessionstorage_directory), | 81 sessionstorage_directory_(sessionstorage_directory), |
| 80 task_runner_(task_runner), | 82 task_runner_(std::move(task_runner)), |
| 81 session_id_offset_( | 83 session_id_offset_(abs((g_session_id_offset_sequence++ % 10)) * |
| 82 abs((g_session_id_offset_sequence++ % 10)) * kSessionIdOffsetAmount), | 84 kSessionIdOffsetAmount), |
| 83 session_id_sequence_(session_id_offset_), | 85 session_id_sequence_(session_id_offset_), |
| 84 is_shutdown_(false), | 86 is_shutdown_(false), |
| 85 force_keep_session_state_(false), | 87 force_keep_session_state_(false), |
| 86 special_storage_policy_(special_storage_policy), | 88 special_storage_policy_(special_storage_policy), |
| 87 scavenging_started_(false), | 89 scavenging_started_(false), |
| 88 is_low_end_device_(base::SysInfo::IsLowEndDevice()) { | 90 is_low_end_device_(base::SysInfo::IsLowEndDevice()) { |
| 89 // Tests may run without task runners. | 91 // Tests may run without task runners. |
| 90 if (task_runner_) { | 92 if (task_runner_) { |
| 91 // Registering dump provider is safe even outside the task runner. | 93 // Registering dump provider is safe even outside the task runner. |
| 92 base::trace_event::MemoryDumpManager::GetInstance() | 94 base::trace_event::MemoryDumpManager::GetInstance() |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 if (!deletable_persistent_namespace_ids_.empty()) { | 631 if (!deletable_persistent_namespace_ids_.empty()) { |
| 630 task_runner_->PostDelayedTask( | 632 task_runner_->PostDelayedTask( |
| 631 FROM_HERE, base::Bind( | 633 FROM_HERE, base::Bind( |
| 632 &DOMStorageContextImpl::DeleteNextUnusedNamespace, | 634 &DOMStorageContextImpl::DeleteNextUnusedNamespace, |
| 633 this), | 635 this), |
| 634 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); | 636 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); |
| 635 } | 637 } |
| 636 } | 638 } |
| 637 | 639 |
| 638 } // namespace content | 640 } // namespace content |
| OLD | NEW |