Index: content/browser/dom_storage/dom_storage_context_impl.cc |
diff --git a/content/browser/dom_storage/dom_storage_context_impl.cc b/content/browser/dom_storage/dom_storage_context_impl.cc |
index db9681cfe72208acbdc22d1d61366e12fbfaad82..0e07dabda9f6729c97ce248e25cd4c8d8547c0e0 100644 |
--- a/content/browser/dom_storage/dom_storage_context_impl.cc |
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc |
@@ -4,6 +4,8 @@ |
#include "content/browser/dom_storage/dom_storage_context_impl.h" |
+#include <stdlib.h> |
+ |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
#include "base/files/file_enumerator.h" |
@@ -26,6 +28,10 @@ namespace content { |
static const int kSessionStoraceScavengingSeconds = 60; |
+// Offset the session storage namespace ids generated by different contexts |
+// to help identify when an id from one is mistakenly used in another. |
+static int g_session_id_offset_sequence = 1; |
+ |
DOMStorageContextImpl::DOMStorageContextImpl( |
const base::FilePath& localstorage_directory, |
const base::FilePath& sessionstorage_directory, |
@@ -34,6 +40,7 @@ DOMStorageContextImpl::DOMStorageContextImpl( |
: localstorage_directory_(localstorage_directory), |
sessionstorage_directory_(sessionstorage_directory), |
task_runner_(task_runner), |
+ session_id_offset_(abs((g_session_id_offset_sequence++ % 10)) * 1000), |
is_shutdown_(false), |
force_keep_session_state_(false), |
special_storage_policy_(special_storage_policy), |
@@ -227,6 +234,10 @@ void DOMStorageContextImpl::NotifyAreaCleared( |
OnDOMStorageAreaCleared(area, page_url)); |
} |
+int64 DOMStorageContextImpl::AllocateSessionId() { |
+ return session_id_sequence_.GetNext() + session_id_offset_; |
+} |
+ |
std::string DOMStorageContextImpl::AllocatePersistentSessionId() { |
std::string guid = base::GenerateGUID(); |
std::replace(guid.begin(), guid.end(), '-', '_'); |