summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 18:43:45 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 18:43:45 +0000
commitc3d634d79a21a64038e5fcb1505904c554ece8ea (patch)
treecc5f5aabc6aeeb5d190fda5f8526050e093eda83 /chrome
parentbb25dfd5d6354dd52f5f693269b807fd4f46161e (diff)
downloadchromium_src-c3d634d79a21a64038e5fcb1505904c554ece8ea.zip
chromium_src-c3d634d79a21a64038e5fcb1505904c554ece8ea.tar.gz
chromium_src-c3d634d79a21a64038e5fcb1505904c554ece8ea.tar.bz2
The SafeBrowsing system had a bunch of plumbing for system resume that wasn't actually hooked to anything. Seems better to not have it than to have it look like it's doing something when it isn't.
BUG=25336 TEST=none Review URL: http://codereview.chromium.org/347024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30607 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database.h3
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_bloom.cc31
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_bloom.h17
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc24
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.h13
5 files changed, 2 insertions, 86 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.h b/chrome/browser/safe_browsing/safe_browsing_database.h
index dd0d49c4..828be6a 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.h
+++ b/chrome/browser/safe_browsing/safe_browsing_database.h
@@ -81,9 +81,6 @@ class SafeBrowsingDatabase {
const std::vector<SBPrefix>& prefixes,
const std::vector<SBFullHashResult>& full_hits) = 0;
- // Called when the user's machine has resumed from a lower power state.
- virtual void HandleResume() = 0;
-
// Returns true if we have successfully started the update transaction.
virtual bool UpdateStarted() = 0;
virtual void UpdateFinished(bool update_succeeded) = 0;
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc
index 53f46a4..9d5a42c 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc
@@ -26,11 +26,6 @@ using base::TimeDelta;
// database is reset.
static const int kDatabaseVersion = 6;
-// When we awake from a low power state, we try to avoid doing expensive disk
-// operations for a few minutes to let the system page itself in and settle
-// down.
-static const int kOnResumeHoldupMs = 5 * 60 * 1000; // 5 minutes.
-
// The maximum staleness for a cached entry.
static const int kMaxStalenessMinutes = 45;
@@ -45,9 +40,7 @@ SafeBrowsingDatabaseBloom::SafeBrowsingDatabaseBloom()
: db_(NULL),
init_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(reset_factory_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(resume_factory_(this)),
- add_count_(0),
- did_resume_(false) {
+ add_count_(0) {
}
SafeBrowsingDatabaseBloom::~SafeBrowsingDatabaseBloom() {
@@ -1206,8 +1199,6 @@ bool SafeBrowsingDatabaseBloom::BuildSubFullHashCache(HashCache* sub_cache) {
return true;
}
-// TODO(erikkay): should we call WaitAfterResume() inside any of the loops here?
-// This is a pretty fast operation and it would be nice to let it finish.
void SafeBrowsingDatabaseBloom::BuildBloomFilter() {
#if defined(OS_WIN)
// For measuring the amount of IO during the bloom filter build.
@@ -1438,26 +1429,6 @@ void SafeBrowsingDatabaseBloom::OnHandleCorruptDatabase() {
DCHECK(false) << "SafeBrowsing database was corrupt and reset";
}
-void SafeBrowsingDatabaseBloom::HandleResume() {
- did_resume_ = true;
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- resume_factory_.NewRunnableMethod(
- &SafeBrowsingDatabaseBloom::OnResumeDone),
- kOnResumeHoldupMs);
-}
-
-void SafeBrowsingDatabaseBloom::OnResumeDone() {
- did_resume_ = false;
-}
-
-void SafeBrowsingDatabaseBloom::WaitAfterResume() {
- if (did_resume_) {
- PlatformThread::Sleep(kOnResumeHoldupMs);
- did_resume_ = false;
- }
-}
-
// This database is always synchronous since we don't need to worry about
// blocking any incoming reads.
void SafeBrowsingDatabaseBloom::SetSynchronous() {
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_bloom.h b/chrome/browser/safe_browsing/safe_browsing_database_bloom.h
index 57e2b27..be3f4e5 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_bloom.h
+++ b/chrome/browser/safe_browsing/safe_browsing_database_bloom.h
@@ -48,7 +48,6 @@ class SafeBrowsingDatabaseBloom : public SafeBrowsingDatabase {
virtual void CacheHashResults(
const std::vector<SBPrefix>& prefixes,
const std::vector<SBFullHashResult>& full_hits);
- virtual void HandleResume();
virtual bool UpdateStarted();
virtual void UpdateFinished(bool update_succeeded);
@@ -125,14 +124,6 @@ class SafeBrowsingDatabaseBloom : public SafeBrowsingDatabase {
void HandleCorruptDatabase();
void OnHandleCorruptDatabase();
- // Clears the did_resume_ flag. This is called by HandleResume after a delay
- // to handle the case where we weren't in the middle of any work.
- void OnResumeDone();
-
- // If the did_resume_ flag is set, sleep for a period and then clear the
- // flag. This method should be called periodically inside of busy disk loops.
- void WaitAfterResume();
-
// Adding add entries to the database.
void InsertAdd(SBPrefix host, SBEntry* entry);
void InsertAddPrefix(SBPrefix prefix, int encoded_chunk);
@@ -196,9 +187,6 @@ class SafeBrowsingDatabaseBloom : public SafeBrowsingDatabase {
// Used to schedule resetting the database because of corruption.
ScopedRunnableMethodFactory<SafeBrowsingDatabaseBloom> reset_factory_;
- // Used to schedule resuming from a lower power state.
- ScopedRunnableMethodFactory<SafeBrowsingDatabaseBloom> resume_factory_;
-
// Caches for all of the existing add and sub chunks.
std::set<int> add_chunk_cache_;
std::set<int> sub_chunk_cache_;
@@ -211,11 +199,6 @@ class SafeBrowsingDatabaseBloom : public SafeBrowsingDatabase {
// size for the bloom filter and stats gathering.
int add_count_;
- // Set to true if the machine just resumed out of a sleep. When this happens,
- // we pause disk activity for some time to avoid thrashing the system while
- // it's presumably going to be pretty busy.
- bool did_resume_;
-
// Transaction for protecting database integrity during updates.
scoped_ptr<SQLTransaction> insert_transaction_;
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index bc06479..09912f2 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -38,13 +38,9 @@ SafeBrowsingService::SafeBrowsingService()
resetting_(false),
database_loaded_(false),
update_in_progress_(false) {
- base::SystemMonitor::Get()->AddObserver(this);
}
SafeBrowsingService::~SafeBrowsingService() {
- base::SystemMonitor* system_monitor = base::SystemMonitor::Get();
- if (system_monitor)
- system_monitor->RemoveObserver(this);
}
// Only called on the UI thread.
@@ -653,26 +649,6 @@ void SafeBrowsingService::CacheHashResults(
GetDatabase()->CacheHashResults(prefixes, full_hashes);
}
-// Tell the SafeBrowsing database not to do expensive disk operations for a few
-// minutes after waking up. It's quite likely that the act of resuming from a
-// low power state will involve much disk activity, which we don't want to
-// exacerbate.
-void SafeBrowsingService::OnResume() {
- if (enabled_) {
- safe_browsing_thread_->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SafeBrowsingService::HandleResume));
- }
-}
-
-void SafeBrowsingService::HandleResume() {
- DCHECK(MessageLoop::current() == safe_browsing_thread_->message_loop());
- // We don't call GetDatabase() here, since we want to avoid unnecessary calls
- // to Open, Reset, etc, or reload the bloom filter while we're coming out of
- // a suspended state.
- if (database_)
- database_->HandleResume();
-}
-
void SafeBrowsingService::RunQueuedClients() {
DCHECK(MessageLoop::current() == io_loop_);
HISTOGRAM_COUNTS("SB.QueueDepth", queued_checks_.size());
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h
index cc994ff..95417b7 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.h
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -16,7 +16,6 @@
#include "base/hash_tables.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
-#include "base/system_monitor.h"
#include "base/thread.h"
#include "base/time.h"
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
@@ -32,8 +31,7 @@ class SafeBrowsingProtocolManager;
// Construction needs to happen on the main thread.
class SafeBrowsingService
- : public base::RefCountedThreadSafe<SafeBrowsingService>,
- public base::SystemMonitor::PowerObserver {
+ : public base::RefCountedThreadSafe<SafeBrowsingService> {
public:
// Users of this service implement this interface to be notified
// asynchronously of the result.
@@ -166,11 +164,6 @@ class SafeBrowsingService
// the current page is 'safe'.
void LogPauseDelay(base::TimeDelta time);
- // PowerObserver notifications
- // We defer SafeBrowsing work for a short duration when the computer comes
- // out of a suspend state to avoid thrashing the disk.
- void OnResume();
-
// Report any pages that contain malware sub-resources to the SafeBrowsing
// service.
void ReportMalware(const GURL& malware_url,
@@ -231,10 +224,6 @@ class SafeBrowsingService
void HandleOneCheck(SafeBrowsingCheck* check,
const std::vector<SBFullHashResult>& full_hashes);
- // Runs on the database thread to inform the database we've resumed from a low
- // power state.
- void HandleResume();
-
// Invoked on the UI thread to show the blocking page.
void DoDisplayBlockingPage(const UnsafeResource& resource);