OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/offline_items_collection/core/android/offline_content_aggre
gator_bridge.h" | 5 #include "components/offline_items_collection/core/android/offline_content_aggre
gator_bridge.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "components/offline_items_collection/core/android/offline_item_bridge.h
" | 10 #include "components/offline_items_collection/core/android/offline_item_bridge.h
" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // static. | 48 // static. |
49 bool OfflineContentAggregatorBridge::Register(JNIEnv* env) { | 49 bool OfflineContentAggregatorBridge::Register(JNIEnv* env) { |
50 return RegisterNativesImpl(env); | 50 return RegisterNativesImpl(env); |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 base::android::ScopedJavaLocalRef<jobject> | 54 base::android::ScopedJavaLocalRef<jobject> |
55 OfflineContentAggregatorBridge::GetBridgeForOfflineContentAggregator( | 55 OfflineContentAggregatorBridge::GetBridgeForOfflineContentAggregator( |
56 OfflineContentAggregator* aggregator) { | 56 OfflineContentAggregator* aggregator) { |
57 if (!aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey)) { | 57 if (!aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey)) { |
58 aggregator->SetUserData(kOfflineContentAggregatorBridgeUserDataKey, | 58 aggregator->SetUserData( |
59 new OfflineContentAggregatorBridge(aggregator)); | 59 kOfflineContentAggregatorBridgeUserDataKey, |
| 60 base::WrapUnique(new OfflineContentAggregatorBridge(aggregator))); |
60 } | 61 } |
61 OfflineContentAggregatorBridge* bridge = | 62 OfflineContentAggregatorBridge* bridge = |
62 static_cast<OfflineContentAggregatorBridge*>( | 63 static_cast<OfflineContentAggregatorBridge*>( |
63 aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey)); | 64 aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey)); |
64 | 65 |
65 return ScopedJavaLocalRef<jobject>(bridge->java_ref_); | 66 return ScopedJavaLocalRef<jobject>(bridge->java_ref_); |
66 } | 67 } |
67 | 68 |
68 OfflineContentAggregatorBridge::OfflineContentAggregatorBridge( | 69 OfflineContentAggregatorBridge::OfflineContentAggregatorBridge( |
69 OfflineContentAggregator* aggregator) | 70 OfflineContentAggregator* aggregator) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 if (java_ref_.is_null()) | 195 if (java_ref_.is_null()) |
195 return; | 196 return; |
196 | 197 |
197 JNIEnv* env = AttachCurrentThread(); | 198 JNIEnv* env = AttachCurrentThread(); |
198 Java_OfflineContentAggregatorBridge_onItemUpdated( | 199 Java_OfflineContentAggregatorBridge_onItemUpdated( |
199 env, java_ref_.obj(), OfflineItemBridge::CreateOfflineItem(env, &item)); | 200 env, java_ref_.obj(), OfflineItemBridge::CreateOfflineItem(env, &item)); |
200 } | 201 } |
201 | 202 |
202 } // namespace android | 203 } // namespace android |
203 } // namespace offline_items_collection | 204 } // namespace offline_items_collection |
OLD | NEW |