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 "base/prefs/pref_member.h" | 5 #include "base/prefs/pref_member.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 registry->RegisterListPref(kStringListPref, new base::ListValue()); | 28 registry->RegisterListPref(kStringListPref, new base::ListValue()); |
29 } | 29 } |
30 | 30 |
31 class GetPrefValueHelper | 31 class GetPrefValueHelper |
32 : public base::RefCountedThreadSafe<GetPrefValueHelper> { | 32 : public base::RefCountedThreadSafe<GetPrefValueHelper> { |
33 public: | 33 public: |
34 GetPrefValueHelper() : value_(false), pref_thread_("pref thread") { | 34 GetPrefValueHelper() : value_(false), pref_thread_("pref thread") { |
35 pref_thread_.Start(); | 35 pref_thread_.Start(); |
36 } | 36 } |
37 | 37 |
38 void Init(const char* pref_name, PrefService* prefs) { | 38 void Init(const std::string& pref_name, PrefService* prefs) { |
39 pref_.Init(pref_name, prefs); | 39 pref_.Init(pref_name, prefs); |
40 pref_.MoveToThread(pref_thread_.message_loop_proxy()); | 40 pref_.MoveToThread(pref_thread_.message_loop_proxy()); |
41 } | 41 } |
42 | 42 |
43 void Destroy() { | 43 void Destroy() { |
44 pref_.Destroy(); | 44 pref_.Destroy(); |
45 } | 45 } |
46 | 46 |
47 void FetchValue() { | 47 void FetchValue() { |
48 base::WaitableEvent event(true, false); | 48 base::WaitableEvent event(true, false); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 helper->FetchValue(); | 312 helper->FetchValue(); |
313 EXPECT_TRUE(helper->value()); | 313 EXPECT_TRUE(helper->value()); |
314 | 314 |
315 helper->Destroy(); | 315 helper->Destroy(); |
316 | 316 |
317 helper->FetchValue(); | 317 helper->FetchValue(); |
318 EXPECT_TRUE(helper->value()); | 318 EXPECT_TRUE(helper->value()); |
319 | 319 |
320 helper->StopThread(); | 320 helper->StopThread(); |
321 } | 321 } |
OLD | NEW |