Skip to content

Commit

Permalink
Revert of SimpleIndex: Temporarily make thread checking active to cha…
Browse files Browse the repository at this point in the history
…se a crash (patchset #2 id:20001 of https://codereview.chromium.org/2822573004/ )

Reason for revert:
Extra checks meant for short-term experiment only.
Didn't catch anything, and we're getting close to new branch.

BUG=710994

Review-Url: https://codereview.chromium.org/2887103003
Cr-Commit-Position: refs/heads/master@{#472497}
  • Loading branch information
morlovich authored and Commit bot committed May 17, 2017
1 parent 3694b9b commit 0a8b311
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
24 changes: 12 additions & 12 deletions net/disk_cache/simple/simple_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ SimpleIndex::SimpleIndex(
app_on_background_(false) {}

SimpleIndex::~SimpleIndex() {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());

// Fail all callbacks waiting for the index to come up.
for (CallbackList::iterator it = to_run_when_initialized_.begin(),
Expand All @@ -150,7 +150,7 @@ SimpleIndex::~SimpleIndex() {
}

void SimpleIndex::Initialize(base::Time cache_mtime) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());

#if defined(OS_ANDROID)
if (base::android::IsVMInitialized()) {
Expand Down Expand Up @@ -178,7 +178,7 @@ void SimpleIndex::SetMaxSize(uint64_t max_bytes) {
}

int SimpleIndex::ExecuteWhenReady(const net::CompletionCallback& task) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
if (initialized_)
io_thread_->PostTask(FROM_HERE, base::Bind(task, net::OK));
else
Expand Down Expand Up @@ -251,7 +251,7 @@ size_t SimpleIndex::EstimateMemoryUsage() const {
}

void SimpleIndex::Insert(uint64_t entry_hash) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
// Upon insert we don't know yet the size of the entry.
// It will be updated later when the SimpleEntryImpl finishes opening or
// creating the new entry, and then UpdateEntrySize will be called.
Expand All @@ -263,7 +263,7 @@ void SimpleIndex::Insert(uint64_t entry_hash) {
}

void SimpleIndex::Remove(uint64_t entry_hash) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
EntrySet::iterator it = entries_set_.find(entry_hash);
if (it != entries_set_.end()) {
UpdateEntryIteratorSize(&it, 0u);
Expand All @@ -282,7 +282,7 @@ bool SimpleIndex::Has(uint64_t hash) const {
}

bool SimpleIndex::UseIfExists(uint64_t entry_hash) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
// Always update the last used time, even if it is during initialization.
// It will be merged later.
EntrySet::iterator it = entries_set_.find(entry_hash);
Expand All @@ -295,7 +295,7 @@ bool SimpleIndex::UseIfExists(uint64_t entry_hash) {
}

void SimpleIndex::StartEvictionIfNeeded() {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
if (eviction_in_progress_ || cache_size_ <= high_watermark_)
return;
// Take all live key hashes from the index and sort them by time.
Expand Down Expand Up @@ -352,7 +352,7 @@ void SimpleIndex::StartEvictionIfNeeded() {

bool SimpleIndex::UpdateEntrySize(uint64_t entry_hash,
base::StrictNumeric<uint32_t> entry_size) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
EntrySet::iterator it = entries_set_.find(entry_hash);
if (it == entries_set_.end())
return false;
Expand All @@ -364,7 +364,7 @@ bool SimpleIndex::UpdateEntrySize(uint64_t entry_hash,
}

void SimpleIndex::EvictionDone(int result) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());

// Ignore the result of eviction. We did our best.
eviction_in_progress_ = false;
Expand Down Expand Up @@ -416,7 +416,7 @@ void SimpleIndex::UpdateEntryIteratorSize(

void SimpleIndex::MergeInitializingSet(
std::unique_ptr<SimpleIndexLoadResult> load_result) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(load_result->did_load);

EntrySet* index_file_entries = &load_result->entries;
Expand Down Expand Up @@ -482,7 +482,7 @@ void SimpleIndex::MergeInitializingSet(
#if defined(OS_ANDROID)
void SimpleIndex::OnApplicationStateChange(
base::android::ApplicationState state) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
// For more info about android activities, see:
// developer.android.com/training/basics/activity-lifecycle/pausing.html
if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) {
Expand All @@ -496,7 +496,7 @@ void SimpleIndex::OnApplicationStateChange(
#endif

void SimpleIndex::WriteToDisk(IndexWriteToDiskReason reason) {
CHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(io_thread_checker_.CalledOnValidThread());
if (!initialized_)
return;
SIMPLE_CACHE_UMA(CUSTOM_COUNTS,
Expand Down
4 changes: 1 addition & 3 deletions net/disk_cache/simple/simple_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ class NET_EXPORT_PRIVATE SimpleIndex

// All nonstatic SimpleEntryImpl methods should always be called on the IO
// thread, in all cases. |io_thread_checker_| documents and enforces this.
// NOTE: Temporarily forced on to chase a crash, https://crbug.com/710994,
// turn off by 2017-04-21, also going back CHECK -> DCHECK in the impl.
base::ThreadCheckerImpl io_thread_checker_;
base::ThreadChecker io_thread_checker_;

// Timestamp of the last time we wrote the index to disk.
// PostponeWritingToDisk() may give up postponing and allow the write if it
Expand Down

0 comments on commit 0a8b311

Please sign in to comment.