| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 VLOG(1) << "Do not use TsfBridge without UI thread."; | 456 VLOG(1) << "Do not use TsfBridge without UI thread."; |
| 457 return false; | 457 return false; |
| 458 } | 458 } |
| 459 tls_tsf_bridge.Initialize(FreeTlsTsfBridgeDelegate); | 459 tls_tsf_bridge.Initialize(FreeTlsTsfBridgeDelegate); |
| 460 TsfBridgeDelegate* delegate = new TsfBridgeDelegate(); | 460 TsfBridgeDelegate* delegate = new TsfBridgeDelegate(); |
| 461 tls_tsf_bridge.Set(delegate); | 461 tls_tsf_bridge.Set(delegate); |
| 462 return delegate->Initialize(); | 462 return delegate->Initialize(); |
| 463 } | 463 } |
| 464 | 464 |
| 465 // static | 465 // static |
| 466 TsfBridge* TsfBridge::ReplaceForTesting(TsfBridge* bridge) { |
| 467 if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { |
| 468 VLOG(1) << "Do not use TsfBridge without UI thread."; |
| 469 return NULL; |
| 470 } |
| 471 TsfBridge* old_bridge = TsfBridge::GetInstance(); |
| 472 tls_tsf_bridge.Set(bridge); |
| 473 return old_bridge; |
| 474 } |
| 475 |
| 476 // static |
| 466 TsfBridge* TsfBridge::GetInstance() { | 477 TsfBridge* TsfBridge::GetInstance() { |
| 467 if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { | 478 if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { |
| 468 VLOG(1) << "Do not use TsfBridge without UI thread."; | 479 VLOG(1) << "Do not use TsfBridge without UI thread."; |
| 469 return NULL; | 480 return NULL; |
| 470 } | 481 } |
| 471 TsfBridgeDelegate* delegate = | 482 TsfBridgeDelegate* delegate = |
| 472 static_cast<TsfBridgeDelegate*>(tls_tsf_bridge.Get()); | 483 static_cast<TsfBridgeDelegate*>(tls_tsf_bridge.Get()); |
| 473 DCHECK(delegate) << "Do no call GetInstance before TsfBridge::Initialize."; | 484 DCHECK(delegate) << "Do no call GetInstance before TsfBridge::Initialize."; |
| 474 return delegate; | 485 return delegate; |
| 475 } | 486 } |
| 476 | 487 |
| 477 } // namespace ui | 488 } // namespace ui |
| OLD | NEW |