OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/prefs/pref_member.h" | 5 #include "chrome/browser/prefs/pref_member.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/prefs/pref_value_store.h" | 9 #include "chrome/browser/prefs/pref_value_store.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 bool value() { return value_; } | 55 bool value() { return value_; } |
56 | 56 |
57 private: | 57 private: |
58 friend class base::RefCountedThreadSafe<GetPrefValueCallback>; | 58 friend class base::RefCountedThreadSafe<GetPrefValueCallback>; |
59 ~GetPrefValueCallback() {} | 59 ~GetPrefValueCallback() {} |
60 | 60 |
61 void GetPrefValueOnIOThread() { | 61 void GetPrefValueOnIOThread() { |
62 value_ = pref_.GetValue(); | 62 value_ = pref_.GetValue(); |
63 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 63 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
64 new MessageLoop::QuitTask()); | 64 MessageLoop::QuitClosure()); |
65 } | 65 } |
66 | 66 |
67 BooleanPrefMember pref_; | 67 BooleanPrefMember pref_; |
68 bool value_; | 68 bool value_; |
69 }; | 69 }; |
70 | 70 |
71 class PrefMemberTestClass : public content::NotificationObserver { | 71 class PrefMemberTestClass : public content::NotificationObserver { |
72 public: | 72 public: |
73 explicit PrefMemberTestClass(PrefService* prefs) | 73 explicit PrefMemberTestClass(PrefService* prefs) |
74 : observe_cnt_(0), prefs_(prefs) { | 74 : observe_cnt_(0), prefs_(prefs) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 callback->Init(kBoolPref, &prefs); | 250 callback->Init(kBoolPref, &prefs); |
251 | 251 |
252 ASSERT_TRUE(callback->FetchValue()); | 252 ASSERT_TRUE(callback->FetchValue()); |
253 EXPECT_FALSE(callback->value()); | 253 EXPECT_FALSE(callback->value()); |
254 | 254 |
255 prefs.SetBoolean(kBoolPref, true); | 255 prefs.SetBoolean(kBoolPref, true); |
256 | 256 |
257 ASSERT_TRUE(callback->FetchValue()); | 257 ASSERT_TRUE(callback->FetchValue()); |
258 EXPECT_TRUE(callback->value()); | 258 EXPECT_TRUE(callback->value()); |
259 } | 259 } |
OLD | NEW |