Index: chrome/browser/extensions/user_script_listener.cc |
=================================================================== |
--- chrome/browser/extensions/user_script_listener.cc (revision 104705) |
+++ chrome/browser/extensions/user_script_listener.cc (working copy) |
@@ -4,13 +4,13 @@ |
#include "chrome/browser/extensions/user_script_listener.h" |
+#include "base/bind.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/extensions/url_pattern.h" |
#include "content/browser/browser_thread.h" |
-#include "content/browser/renderer_host/global_request_id.h" |
#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
#include "content/common/notification_service.h" |
#include "net/url_request/url_request.h" |
@@ -18,7 +18,7 @@ |
UserScriptListener::UserScriptListener() |
: resource_queue_(NULL), |
user_scripts_ready_(false) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
NotificationService::AllSources()); |
@@ -37,7 +37,7 @@ |
net::URLRequest* request, |
const ResourceDispatcherHostRequestInfo& request_info, |
const GlobalRequestID& request_id) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
// If it's a frame load, then we need to check the URL against the list of |
// user scripts to see if we need to wait. |
@@ -54,7 +54,6 @@ |
if ((*it).MatchesURL(request->url())) { |
// One of the user scripts wants to inject into this request, but the |
// script isn't ready yet. Delay the request. |
- delayed_request_ids_.push_front(request_id); |
return true; |
} |
} |
@@ -63,34 +62,29 @@ |
} |
void UserScriptListener::WillShutdownResourceQueue() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
resource_queue_ = NULL; |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
- NewRunnableMethod(this, &UserScriptListener::Cleanup)); |
+ base::Bind(&UserScriptListener::Cleanup, this)); |
} |
UserScriptListener::~UserScriptListener() { |
} |
void UserScriptListener::StartDelayedRequests() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
user_scripts_ready_ = true; |
if (resource_queue_) { |
- for (DelayedRequests::iterator it = delayed_request_ids_.begin(); |
- it != delayed_request_ids_.end(); ++it) { |
- resource_queue_->StartDelayedRequest(this, *it); |
- } |
+ resource_queue_->StartDelayedRequests(this); |
} |
- |
- delayed_request_ids_.clear(); |
} |
void UserScriptListener::AppendNewURLPatterns(const URLPatterns& new_patterns) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
user_scripts_ready_ = false; |
url_patterns_.insert(url_patterns_.end(), |
@@ -98,19 +92,19 @@ |
} |
void UserScriptListener::ReplaceURLPatterns(const URLPatterns& patterns) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
url_patterns_ = patterns; |
} |
void UserScriptListener::Cleanup() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
registrar_.RemoveAll(); |
Release(); |
} |
void UserScriptListener::CollectURLPatterns(const Extension* extension, |
URLPatterns* patterns) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
const UserScriptList& scripts = extension->content_scripts(); |
for (UserScriptList::const_iterator iter = scripts.begin(); |
@@ -124,7 +118,7 @@ |
void UserScriptListener::Observe(int type, |
const NotificationSource& source, |
const NotificationDetails& details) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
switch (type) { |
case chrome::NOTIFICATION_EXTENSION_LOADED: { |
@@ -138,8 +132,8 @@ |
if (!new_patterns.empty()) { |
BrowserThread::PostTask( |
BrowserThread::IO, FROM_HERE, |
- NewRunnableMethod( |
- this, &UserScriptListener::AppendNewURLPatterns, new_patterns)); |
+ base::Bind( |
+ &UserScriptListener::AppendNewURLPatterns, this, new_patterns)); |
} |
break; |
} |
@@ -161,15 +155,15 @@ |
} |
BrowserThread::PostTask( |
BrowserThread::IO, FROM_HERE, |
- NewRunnableMethod( |
- this, &UserScriptListener::ReplaceURLPatterns, new_patterns)); |
+ base::Bind( |
+ &UserScriptListener::ReplaceURLPatterns, this, new_patterns)); |
break; |
} |
case chrome::NOTIFICATION_USER_SCRIPTS_UPDATED: { |
BrowserThread::PostTask( |
BrowserThread::IO, FROM_HERE, |
- NewRunnableMethod(this, &UserScriptListener::StartDelayedRequests)); |
+ base::Bind(&UserScriptListener::StartDelayedRequests, this)); |
break; |
} |