OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <msctf.h> | 5 #include <msctf.h> |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 VLOG(1) << "Do not use TsfBridge without UI thread."; | 320 VLOG(1) << "Do not use TsfBridge without UI thread."; |
321 return false; | 321 return false; |
322 } | 322 } |
323 tls_tsf_bridge.Initialize(FreeTlsTsfBridgeDelegate); | 323 tls_tsf_bridge.Initialize(FreeTlsTsfBridgeDelegate); |
324 TsfBridgeDelegate* delegate = new TsfBridgeDelegate(); | 324 TsfBridgeDelegate* delegate = new TsfBridgeDelegate(); |
325 tls_tsf_bridge.Set(delegate); | 325 tls_tsf_bridge.Set(delegate); |
326 return delegate->Initialize(); | 326 return delegate->Initialize(); |
327 } | 327 } |
328 | 328 |
329 // static | 329 // static |
330 TsfBridge* TsfBridge::ReplaceForTesting(TsfBridge* bridge) { | |
331 if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { | |
332 VLOG(1) << "Do not use TsfBridge without UI thread."; | |
333 return NULL; | |
334 } | |
335 TsfBridge* old_bridge = TsfBridge::GetInstance(); | |
sky
2012/09/10 16:44:09
Who owns old_bridge?
Seigo Nonaka
2012/09/10 19:04:10
The caller should release old_bridge.
Revise comme
| |
336 tls_tsf_bridge.Set(bridge); | |
337 return old_bridge; | |
338 } | |
339 | |
340 // static | |
330 TsfBridge* TsfBridge::GetInstance() { | 341 TsfBridge* TsfBridge::GetInstance() { |
331 if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { | 342 if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { |
332 VLOG(1) << "Do not use TsfBridge without UI thread."; | 343 VLOG(1) << "Do not use TsfBridge without UI thread."; |
333 return NULL; | 344 return NULL; |
334 } | 345 } |
335 TsfBridgeDelegate* delegate = | 346 TsfBridgeDelegate* delegate = |
336 static_cast<TsfBridgeDelegate*>(tls_tsf_bridge.Get()); | 347 static_cast<TsfBridgeDelegate*>(tls_tsf_bridge.Get()); |
337 DCHECK(delegate) << "Do no call GetInstance before TsfBridge::Initialize."; | 348 DCHECK(delegate) << "Do no call GetInstance before TsfBridge::Initialize."; |
338 return delegate; | 349 return delegate; |
339 } | 350 } |
340 | 351 |
341 } // namespace ui | 352 } // namespace ui |
OLD | NEW |