Commit 7bdc4a49 authored by thestig's avatar thestig Committed by Commit bot

Revert of offset namespace ids (patchset #7 id:120001 of...

Revert of offset namespace ids (patchset #7 id:120001 of https://codereview.chromium.org/881253004/)

Reason for revert:
Tests now only work if they ran in the "right" order. DOMStorageContextImplTest.Basic fails if the tests are shuffled:

content_unittests --gtest_filter=DOMStorageContextImplTest.*:DOMStorageAreaTest.* --gtest_shuffle

Original issue's description:
> [DOMStorage] Offset the session storage namespace ids generated by different contexts to help identify when an id from one is mistakenly used in another.
>
> Committed: https://crrev.com/36dcef3da5317365ab95e50a5f6b7fa98ada1d5e
> Cr-Commit-Position: refs/heads/master@{#314256}

TBR=jsbell@chromium.org,michaeln@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/896733002

Cr-Commit-Position: refs/heads/master@{#314274}
parent 534f316d
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "content/browser/dom_storage/dom_storage_context_impl.h" #include "content/browser/dom_storage/dom_storage_context_impl.h"
#include <stdlib.h>
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
...@@ -28,10 +26,6 @@ namespace content { ...@@ -28,10 +26,6 @@ namespace content {
static const int kSessionStoraceScavengingSeconds = 60; 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 = 0;
DOMStorageContextImpl::DOMStorageContextImpl( DOMStorageContextImpl::DOMStorageContextImpl(
const base::FilePath& localstorage_directory, const base::FilePath& localstorage_directory,
const base::FilePath& sessionstorage_directory, const base::FilePath& sessionstorage_directory,
...@@ -40,7 +34,6 @@ DOMStorageContextImpl::DOMStorageContextImpl( ...@@ -40,7 +34,6 @@ DOMStorageContextImpl::DOMStorageContextImpl(
: localstorage_directory_(localstorage_directory), : localstorage_directory_(localstorage_directory),
sessionstorage_directory_(sessionstorage_directory), sessionstorage_directory_(sessionstorage_directory),
task_runner_(task_runner), task_runner_(task_runner),
session_id_offset_(abs((g_session_id_offset_sequence++ % 10)) * 1000),
is_shutdown_(false), is_shutdown_(false),
force_keep_session_state_(false), force_keep_session_state_(false),
special_storage_policy_(special_storage_policy), special_storage_policy_(special_storage_policy),
...@@ -234,10 +227,6 @@ void DOMStorageContextImpl::NotifyAreaCleared( ...@@ -234,10 +227,6 @@ void DOMStorageContextImpl::NotifyAreaCleared(
OnDOMStorageAreaCleared(area, page_url)); OnDOMStorageAreaCleared(area, page_url));
} }
int64 DOMStorageContextImpl::AllocateSessionId() {
return session_id_sequence_.GetNext() + session_id_offset_;
}
std::string DOMStorageContextImpl::AllocatePersistentSessionId() { std::string DOMStorageContextImpl::AllocatePersistentSessionId() {
std::string guid = base::GenerateGUID(); std::string guid = base::GenerateGUID();
std::replace(guid.begin(), guid.end(), '-', '_'); std::replace(guid.begin(), guid.end(), '-', '_');
......
...@@ -147,7 +147,10 @@ class CONTENT_EXPORT DOMStorageContextImpl ...@@ -147,7 +147,10 @@ class CONTENT_EXPORT DOMStorageContextImpl
const GURL& page_url); const GURL& page_url);
// May be called on any thread. // May be called on any thread.
int64 AllocateSessionId(); int64 AllocateSessionId() {
return session_id_sequence_.GetNext();
}
std::string AllocatePersistentSessionId(); std::string AllocatePersistentSessionId();
// Must be called on the background thread. // Must be called on the background thread.
...@@ -204,10 +207,7 @@ class CONTENT_EXPORT DOMStorageContextImpl ...@@ -204,10 +207,7 @@ class CONTENT_EXPORT DOMStorageContextImpl
// We use a 32 bit identifier for per tab storage sessions. // We use a 32 bit identifier for per tab storage sessions.
// At a tab per second, this range is large enough for 68 years. // At a tab per second, this range is large enough for 68 years.
// The offset is to more quickly detect the error condition where
// an id related to one context is mistakenly used in another.
base::AtomicSequenceNumber session_id_sequence_; base::AtomicSequenceNumber session_id_sequence_;
const int session_id_offset_;
bool is_shutdown_; bool is_shutdown_;
bool force_keep_session_state_; bool force_keep_session_state_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment