Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Side by Side Diff: components/offline_items_collection/core/android/offline_content_aggregator_bridge.cc

Issue 2729983002: Attaches OfflineContentAggregator to Profile (Closed)
Patch Set: Address nit Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/offline_items_collection/core/android/offline_item_bridge.h " 8 #include "components/offline_items_collection/core/android/offline_item_bridge.h "
9 #include "components/offline_items_collection/core/offline_item.h" 9 #include "components/offline_items_collection/core/offline_item.h"
10 #include "jni/OfflineContentAggregatorBridge_jni.h" 10 #include "jni/OfflineContentAggregatorBridge_jni.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 // static. 33 // static.
34 bool OfflineContentAggregatorBridge::Register(JNIEnv* env) { 34 bool OfflineContentAggregatorBridge::Register(JNIEnv* env) {
35 return RegisterNativesImpl(env); 35 return RegisterNativesImpl(env);
36 } 36 }
37 37
38 // static 38 // static
39 OfflineContentAggregatorBridge* 39 base::android::ScopedJavaLocalRef<jobject>
40 OfflineContentAggregatorBridge::GetForOfflineContentAggregator( 40 OfflineContentAggregatorBridge::GetBridgeForOfflineContentAggregator(
41 OfflineContentAggregator* aggregator) { 41 OfflineContentAggregator* aggregator) {
42 if (!aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey)) { 42 if (!aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey)) {
43 aggregator->SetUserData(kOfflineContentAggregatorBridgeUserDataKey, 43 aggregator->SetUserData(kOfflineContentAggregatorBridgeUserDataKey,
44 new OfflineContentAggregatorBridge(aggregator)); 44 new OfflineContentAggregatorBridge(aggregator));
45 } 45 }
46 OfflineContentAggregatorBridge* bridge =
47 static_cast<OfflineContentAggregatorBridge*>(
48 aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey));
46 49
47 return static_cast<OfflineContentAggregatorBridge*>( 50 return ScopedJavaLocalRef<jobject>(bridge->java_ref_);
48 aggregator->GetUserData(kOfflineContentAggregatorBridgeUserDataKey));
49 } 51 }
50 52
51 OfflineContentAggregatorBridge::OfflineContentAggregatorBridge( 53 OfflineContentAggregatorBridge::OfflineContentAggregatorBridge(
52 OfflineContentAggregator* aggregator) 54 OfflineContentAggregator* aggregator)
53 : aggregator_(aggregator) { 55 : aggregator_(aggregator) {
54 JNIEnv* env = AttachCurrentThread(); 56 JNIEnv* env = AttachCurrentThread();
55 java_ref_.Reset(Java_OfflineContentAggregatorBridge_create( 57 java_ref_.Reset(Java_OfflineContentAggregatorBridge_create(
56 env, reinterpret_cast<intptr_t>(this))); 58 env, reinterpret_cast<intptr_t>(this)));
57 59
58 aggregator_->AddObserver(this); 60 aggregator_->AddObserver(this);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 if (java_ref_.is_null()) 167 if (java_ref_.is_null())
166 return; 168 return;
167 169
168 JNIEnv* env = AttachCurrentThread(); 170 JNIEnv* env = AttachCurrentThread();
169 Java_OfflineContentAggregatorBridge_onItemUpdated( 171 Java_OfflineContentAggregatorBridge_onItemUpdated(
170 env, java_ref_.obj(), OfflineItemBridge::CreateOfflineItem(env, &item)); 172 env, java_ref_.obj(), OfflineItemBridge::CreateOfflineItem(env, &item));
171 } 173 }
172 174
173 } // namespace android 175 } // namespace android
174 } // namespace offline_items_collection 176 } // namespace offline_items_collection
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698