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

Side by Side Diff: chrome/browser/android/foreign_session_helper.cc

Issue 257513007: [Android] ForeignSessionHelper string memory leak fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: only loop was the problem Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/android/foreign_session_helper.h" 5 #include "chrome/browser/android/foreign_session_helper.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 DCHECK(selected_index >= 0); 99 DCHECK(selected_index >= 0);
100 DCHECK(selected_index < static_cast<int>(session_tab.navigations.size())); 100 DCHECK(selected_index < static_cast<int>(session_tab.navigations.size()));
101 101
102 const ::sessions::SerializedNavigationEntry& current_navigation = 102 const ::sessions::SerializedNavigationEntry& current_navigation =
103 session_tab.navigations.at(selected_index); 103 session_tab.navigations.at(selected_index);
104 104
105 GURL tab_url = current_navigation.virtual_url(); 105 GURL tab_url = current_navigation.virtual_url();
106 106
107 Java_ForeignSessionHelper_pushTab( 107 Java_ForeignSessionHelper_pushTab(
108 env, j_window.obj(), 108 env, j_window.obj(),
109 ConvertUTF8ToJavaString(env, tab_url.spec()).Release(), 109 ConvertUTF8ToJavaString(env, tab_url.spec()).obj(),
110 ConvertUTF16ToJavaString(env, current_navigation.title()).Release(), 110 ConvertUTF16ToJavaString(env, current_navigation.title()).obj(),
111 session_tab.timestamp.ToJavaTime(), 111 session_tab.timestamp.ToJavaTime(),
112 session_tab.tab_id.id()); 112 session_tab.tab_id.id());
113 } 113 }
114 } 114 }
115 115
116 void CopyWindowsToJava( 116 void CopyWindowsToJava(
117 JNIEnv* env, 117 JNIEnv* env,
118 const SyncedSession& session, 118 const SyncedSession& session,
119 ScopedJavaLocalRef<jobject>& j_session) { 119 ScopedJavaLocalRef<jobject>& j_session) {
120 for (SyncedSession::SyncedWindowMap::const_iterator it = 120 for (SyncedSession::SyncedWindowMap::const_iterator it =
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 const bool is_collapsed = collapsed_sessions->HasKey(session.session_tag); 230 const bool is_collapsed = collapsed_sessions->HasKey(session.session_tag);
231 231
232 if (is_collapsed) 232 if (is_collapsed)
233 pref_collapsed_sessions->SetBoolean(session.session_tag, true); 233 pref_collapsed_sessions->SetBoolean(session.session_tag, true);
234 234
235 last_pushed_session.Reset( 235 last_pushed_session.Reset(
236 Java_ForeignSessionHelper_pushSession( 236 Java_ForeignSessionHelper_pushSession(
237 env, 237 env,
238 result, 238 result,
239 ConvertUTF8ToJavaString(env, session.session_tag).Release(), 239 ConvertUTF8ToJavaString(env, session.session_tag).obj(),
240 ConvertUTF8ToJavaString(env, session.session_name).Release(), 240 ConvertUTF8ToJavaString(env, session.session_name).obj(),
241 session.device_type, 241 session.device_type,
242 session.modified_time.ToJavaTime())); 242 session.modified_time.ToJavaTime()));
243 243
244 CopyWindowsToJava(env, session, last_pushed_session); 244 CopyWindowsToJava(env, session, last_pushed_session);
245 } 245 }
246 246
247 return true; 247 return true;
248 } 248 }
249 249
250 jboolean ForeignSessionHelper::OpenForeignSessionTab(JNIEnv* env, 250 jboolean ForeignSessionHelper::OpenForeignSessionTab(JNIEnv* env,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 jstring session_tag) { 293 jstring session_tag) {
294 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); 294 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_);
295 if (open_tabs) 295 if (open_tabs)
296 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); 296 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag));
297 } 297 }
298 298
299 // static 299 // static
300 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { 300 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) {
301 return RegisterNativesImpl(env); 301 return RegisterNativesImpl(env);
302 } 302 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698