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

Side by Side Diff: chrome/browser/profiles/profile_android.cc

Issue 2842833003: Update SupportsUserData uses with unique_ptr. (Closed)
Patch Set: rebase Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/profiles/profile_android.h" 5 #include "chrome/browser/profiles/profile_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/profiles/profile_destroyer.h" 10 #include "chrome/browser/profiles/profile_destroyer.h"
10 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
11 #include "jni/Profile_jni.h" 12 #include "jni/Profile_jni.h"
12 13
13 using base::android::AttachCurrentThread; 14 using base::android::AttachCurrentThread;
14 using base::android::JavaParamRef; 15 using base::android::JavaParamRef;
15 using base::android::ScopedJavaLocalRef; 16 using base::android::ScopedJavaLocalRef;
16 17
17 namespace { 18 namespace {
18 const char kProfileAndroidKey[] = "profile_android"; 19 const char kProfileAndroidKey[] = "profile_android";
19 } // namespace 20 } // namespace
20 21
21 // static 22 // static
22 ProfileAndroid* ProfileAndroid::FromProfile(Profile* profile) { 23 ProfileAndroid* ProfileAndroid::FromProfile(Profile* profile) {
23 if (!profile) 24 if (!profile)
24 return NULL; 25 return NULL;
25 26
26 ProfileAndroid* profile_android = static_cast<ProfileAndroid*>( 27 ProfileAndroid* profile_android = static_cast<ProfileAndroid*>(
27 profile->GetUserData(kProfileAndroidKey)); 28 profile->GetUserData(kProfileAndroidKey));
28 if (!profile_android) { 29 if (!profile_android) {
29 profile_android = new ProfileAndroid(profile); 30 profile_android = new ProfileAndroid(profile);
30 profile->SetUserData(kProfileAndroidKey, profile_android); 31 profile->SetUserData(kProfileAndroidKey, base::WrapUnique(profile_android));
31 } 32 }
32 return profile_android; 33 return profile_android;
33 } 34 }
34 35
35 // static 36 // static
36 Profile* ProfileAndroid::FromProfileAndroid(jobject obj) { 37 Profile* ProfileAndroid::FromProfileAndroid(jobject obj) {
37 if (!obj) 38 if (!obj)
38 return NULL; 39 return NULL;
39 40
40 ProfileAndroid* profile_android = reinterpret_cast<ProfileAndroid*>( 41 ProfileAndroid* profile_android = reinterpret_cast<ProfileAndroid*>(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 obj_.Reset(env, jprofile.obj()); 119 obj_.Reset(env, jprofile.obj());
119 } 120 }
120 121
121 ProfileAndroid::~ProfileAndroid() { 122 ProfileAndroid::~ProfileAndroid() {
122 Java_Profile_onNativeDestroyed(AttachCurrentThread(), obj_); 123 Java_Profile_onNativeDestroyed(AttachCurrentThread(), obj_);
123 } 124 }
124 125
125 base::android::ScopedJavaLocalRef<jobject> ProfileAndroid::GetJavaObject() { 126 base::android::ScopedJavaLocalRef<jobject> ProfileAndroid::GetJavaObject() {
126 return base::android::ScopedJavaLocalRef<jobject>(obj_); 127 return base::android::ScopedJavaLocalRef<jobject>(obj_);
127 } 128 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager_test_base.cc ('k') | chrome/browser/search/instant_io_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698