| Index: chrome/browser/user_style_sheet_watcher.cc
|
| diff --git a/chrome/browser/user_style_sheet_watcher.cc b/chrome/browser/user_style_sheet_watcher.cc
|
| index a8774b5f01ac06c167eba1724a96eb5981f43fb1..be713197fb6fac67317af382183ef0a87845af59 100644
|
| --- a/chrome/browser/user_style_sheet_watcher.cc
|
| +++ b/chrome/browser/user_style_sheet_watcher.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/base64.h"
|
| #include "base/bind.h"
|
| +#include "base/callback_list.h"
|
| #include "base/file_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -57,7 +58,8 @@ class UserStyleSheetLoader
|
| void LoadStyleSheet(const base::FilePath& style_sheet_file);
|
|
|
| // Register a callback to be called whenever the stylesheet gets updated.
|
| - void RegisterOnStyleSheetUpdatedCallback(const base::Closure& callback);
|
| + base::Closure RegisterOnStyleSheetUpdatedCallback(
|
| + const base::Closure& callback);
|
|
|
| // Send out a notification if the stylesheet has already been loaded.
|
| void NotifyLoaded();
|
| @@ -78,7 +80,7 @@ class UserStyleSheetLoader
|
| // Whether the stylesheet has been loaded.
|
| bool has_loaded_;
|
|
|
| - std::vector<base::Closure> on_loaded_callbacks_;
|
| + CallbackList<base::Closure> on_loaded_callbacks_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(UserStyleSheetLoader);
|
| };
|
| @@ -87,18 +89,14 @@ UserStyleSheetLoader::UserStyleSheetLoader()
|
| : has_loaded_(false) {
|
| }
|
|
|
| -void UserStyleSheetLoader::RegisterOnStyleSheetUpdatedCallback(
|
| +base::Closure UserStyleSheetLoader::RegisterOnStyleSheetUpdatedCallback(
|
| const base::Closure& callback) {
|
| - on_loaded_callbacks_.push_back(callback);
|
| + return on_loaded_callbacks_.RegisterCallback(callback);
|
| }
|
|
|
| void UserStyleSheetLoader::NotifyLoaded() {
|
| - if (has_loaded_) {
|
| - for (size_t i = 0; i < on_loaded_callbacks_.size(); ++i) {
|
| - if (!on_loaded_callbacks_[i].is_null())
|
| - on_loaded_callbacks_[i].Run();
|
| - }
|
| - }
|
| + if (has_loaded_)
|
| + FOR_EACH_CALLBACK(base::Closure, on_loaded_callbacks_);
|
| }
|
|
|
| void UserStyleSheetLoader::NotifyPathChanged(const base::FilePath& path,
|
| @@ -139,7 +137,7 @@ void UserStyleSheetLoader::LoadStyleSheet(
|
| }
|
|
|
| UserStyleSheetLoader::~UserStyleSheetLoader() {
|
| - on_loaded_callbacks_.clear();
|
| + on_loaded_callbacks_.Clear();
|
| }
|
|
|
| void UserStyleSheetLoader::SetStyleSheet(const GURL& url) {
|
| @@ -194,9 +192,9 @@ GURL UserStyleSheetWatcher::user_style_sheet() const {
|
| return loader_->user_style_sheet();
|
| }
|
|
|
| -void UserStyleSheetWatcher::RegisterOnStyleSheetUpdatedCallback(
|
| +base::Closure UserStyleSheetWatcher::RegisterOnStyleSheetUpdatedCallback(
|
| const base::Closure& callback) {
|
| - loader_->RegisterOnStyleSheetUpdatedCallback(callback);
|
| + return loader_->RegisterOnStyleSheetUpdatedCallback(callback);
|
| }
|
|
|
| void UserStyleSheetWatcher::Observe(int type,
|
|
|