summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/extensions/extension_l10n_util.cc4
-rw-r--r--chrome/common/notification_registrar.cc30
-rw-r--r--chrome/common/notification_registrar.h5
3 files changed, 14 insertions, 25 deletions
diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc
index e7406b2..1de16fe 100644
--- a/chrome/common/extensions/extension_l10n_util.cc
+++ b/chrome/common/extensions/extension_l10n_util.cc
@@ -13,7 +13,6 @@
#include "base/linked_ptr.h"
#include "base/string_util.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_file_util.h"
@@ -174,8 +173,7 @@ std::string NormalizeLocale(const std::string& locale) {
}
std::string CurrentLocaleOrDefault() {
- std::string current_locale =
- NormalizeLocale(g_browser_process->GetApplicationLocale());
+ std::string current_locale = NormalizeLocale(*GetProcessLocale());
if (current_locale.empty())
current_locale = "en";
diff --git a/chrome/common/notification_registrar.cc b/chrome/common/notification_registrar.cc
index 9119a5d..175a3f6 100644
--- a/chrome/common/notification_registrar.cc
+++ b/chrome/common/notification_registrar.cc
@@ -15,7 +15,7 @@ struct NotificationRegistrar::Record {
NotificationObserver* observer;
NotificationType type;
NotificationSource source;
- ChromeThread::ID thread_id;
+ PlatformThreadId thread_id;
};
bool NotificationRegistrar::Record::operator==(const Record& other) const {
@@ -35,7 +35,7 @@ NotificationRegistrar::~NotificationRegistrar() {
void NotificationRegistrar::Add(NotificationObserver* observer,
NotificationType type,
const NotificationSource& source) {
- Record record = { observer, type, source, GetCurrentThreadIdentifier() };
+ Record record = { observer, type, source, PlatformThread::CurrentId() };
DCHECK(std::find(registered_.begin(), registered_.end(), record) ==
registered_.end()) << "Duplicate registration.";
@@ -55,7 +55,7 @@ void NotificationRegistrar::Remove(NotificationObserver* observer,
type.value << " from list of size " << registered_.size() << ".";
return;
}
- CheckCalledOnValidWellKnownThread(found->thread_id);
+ CheckCalledOnValidThread(found->thread_id);
registered_.erase(found);
@@ -82,7 +82,7 @@ void NotificationRegistrar::RemoveAll() {
NotificationService* service = NotificationService::current();
if (service) {
for (size_t i = 0; i < registered_.size(); i++) {
- CheckCalledOnValidWellKnownThread(registered_[i].thread_id);
+ CheckCalledOnValidThread(registered_[i].thread_id);
service->RemoveObserver(registered_[i].observer,
registered_[i].type,
registered_[i].source);
@@ -95,19 +95,11 @@ bool NotificationRegistrar::IsEmpty() const {
return registered_.empty();
}
-ChromeThread::ID NotificationRegistrar::GetCurrentThreadIdentifier() {
- ChromeThread::ID thread_id;
- if (!ChromeThread::GetCurrentThreadIdentifier(&thread_id)) {
- // If we are not created in well known thread, GetCurrentThreadIdentifier
- // fails. Assign thread_id to an ID not used.
- thread_id = ChromeThread::ID_COUNT;
- }
- return thread_id;
-}
-
-void NotificationRegistrar::CheckCalledOnValidWellKnownThread(
- ChromeThread::ID thread_id) {
- if (ChromeThread::IsWellKnownThread(thread_id)) {
- CHECK(ChromeThread::CurrentlyOn(thread_id));
- }
+// static
+void NotificationRegistrar::CheckCalledOnValidThread(
+ PlatformThreadId thread_id) {
+ PlatformThreadId current_thread_id = PlatformThread::CurrentId();
+ CHECK(current_thread_id == thread_id) << "called on invalid thread: "
+ << thread_id << " vs. "
+ << current_thread_id;
}
diff --git a/chrome/common/notification_registrar.h b/chrome/common/notification_registrar.h
index 3d71783..03f86e6 100644
--- a/chrome/common/notification_registrar.h
+++ b/chrome/common/notification_registrar.h
@@ -8,7 +8,7 @@
#include <vector>
#include "base/basictypes.h"
-#include "chrome/browser/chrome_thread.h"
+#include "base/platform_thread.h"
#include "chrome/common/notification_observer.h"
// Aids in registering for notifications and ensures that all registered
@@ -40,8 +40,7 @@ class NotificationRegistrar {
bool IsEmpty() const;
private:
- ChromeThread::ID GetCurrentThreadIdentifier();
- void CheckCalledOnValidWellKnownThread(ChromeThread::ID thread_id);
+ static void CheckCalledOnValidThread(PlatformThreadId thread_id);
struct Record;