| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/dummy_blimp_client_context.h" | 5 #include "blimp/client/core/dummy_blimp_client_context.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 9 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 10 #include "base/supports_user_data.h" | |
| 11 #include "blimp/client/public/blimp_client_context_delegate.h" | |
| 12 | 9 |
| 13 #if defined(OS_ANDROID) | 10 #if defined(OS_ANDROID) |
| 14 #include "blimp/client/core/android/dummy_blimp_client_context_android.h" | 11 #include "blimp/client/core/android/dummy_blimp_client_context_android.h" |
| 15 #endif // OS_ANDROID | 12 #endif // OS_ANDROID |
| 16 | 13 |
| 17 namespace blimp { | 14 namespace blimp { |
| 18 namespace client { | 15 namespace client { |
| 19 | 16 |
| 20 namespace { | |
| 21 | |
| 22 #if defined(OS_ANDROID) | |
| 23 const char kDummyBlimpClientContextAndroidKey[] = | |
| 24 "dummy_blimp_client_context_android"; | |
| 25 #endif // OS_ANDROID | |
| 26 } | |
| 27 | |
| 28 // This function is declared in //blimp/client/public/blimp_client_context.h, | 17 // This function is declared in //blimp/client/public/blimp_client_context.h, |
| 29 // and either this function or the one in | 18 // and either this function or the one in |
| 30 // //blimp/client/core/blimp_client_context_impl.cc should be linked in to | 19 // //blimp/client/core/blimp_client_context_impl.cc should be linked in to |
| 31 // any binary using BlimpClientContext::Create. | 20 // any binary using BlimpClientContext::Create. |
| 32 // static | 21 // static |
| 33 BlimpClientContext* BlimpClientContext::Create( | 22 BlimpClientContext* BlimpClientContext::Create( |
| 34 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) { | 23 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) { |
| 24 #if defined(OS_ANDROID) |
| 25 return new DummyBlimpClientContextAndroid(); |
| 26 #else |
| 35 return new DummyBlimpClientContext(); | 27 return new DummyBlimpClientContext(); |
| 28 #endif // defined(OS_ANDROID) |
| 36 } | 29 } |
| 37 | 30 |
| 38 DummyBlimpClientContext::DummyBlimpClientContext() : BlimpClientContext() {} | 31 DummyBlimpClientContext::DummyBlimpClientContext() : BlimpClientContext() {} |
| 39 | 32 |
| 40 DummyBlimpClientContext::~DummyBlimpClientContext() {} | 33 DummyBlimpClientContext::~DummyBlimpClientContext() {} |
| 41 | 34 |
| 42 #if defined(OS_ANDROID) | |
| 43 | |
| 44 base::android::ScopedJavaLocalRef<jobject> | |
| 45 DummyBlimpClientContext::GetJavaObject() { | |
| 46 return GetDummyBlimpClientContextAndroid()->GetJavaObject(); | |
| 47 } | |
| 48 | |
| 49 DummyBlimpClientContextAndroid* | |
| 50 DummyBlimpClientContext::GetDummyBlimpClientContextAndroid() { | |
| 51 DummyBlimpClientContextAndroid* dummy_blimp_client_contents_android = | |
| 52 static_cast<DummyBlimpClientContextAndroid*>( | |
| 53 GetUserData(kDummyBlimpClientContextAndroidKey)); | |
| 54 if (!dummy_blimp_client_contents_android) { | |
| 55 dummy_blimp_client_contents_android = new DummyBlimpClientContextAndroid(); | |
| 56 SetUserData(kDummyBlimpClientContextAndroidKey, | |
| 57 dummy_blimp_client_contents_android); | |
| 58 } | |
| 59 return dummy_blimp_client_contents_android; | |
| 60 } | |
| 61 | |
| 62 #endif // defined(OS_ANDROID) | |
| 63 | |
| 64 void DummyBlimpClientContext::SetDelegate( | 35 void DummyBlimpClientContext::SetDelegate( |
| 65 BlimpClientContextDelegate* delegate) {} | 36 BlimpClientContextDelegate* delegate) {} |
| 66 | 37 |
| 67 std::unique_ptr<BlimpContents> DummyBlimpClientContext::CreateBlimpContents() { | 38 std::unique_ptr<BlimpContents> DummyBlimpClientContext::CreateBlimpContents() { |
| 68 return nullptr; | 39 return nullptr; |
| 69 } | 40 } |
| 70 | 41 |
| 71 } // namespace client | 42 } // namespace client |
| 72 } // namespace blimp | 43 } // namespace blimp |
| OLD | NEW |