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

Side by Side Diff: ui/base/dragdrop/gtk_dnd_util.cc

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/dragdrop/gtk_dnd_util.h" 5 #include "ui/base/dragdrop/gtk_dnd_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 bool ExtractNamedURL(GtkSelectionData* selection_data, 209 bool ExtractNamedURL(GtkSelectionData* selection_data,
210 GURL* url, 210 GURL* url,
211 string16* title) { 211 string16* title) {
212 if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0) 212 if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0)
213 return false; 213 return false;
214 214
215 Pickle data( 215 Pickle data(
216 reinterpret_cast<const char*>( 216 reinterpret_cast<const char*>(
217 gtk_selection_data_get_data(selection_data)), 217 gtk_selection_data_get_data(selection_data)),
218 gtk_selection_data_get_length(selection_data)); 218 gtk_selection_data_get_length(selection_data));
219 void* iter = NULL; 219 PickleIterator iter(data);
220 std::string title_utf8, url_utf8; 220 std::string title_utf8, url_utf8;
221 if (!data.ReadString(&iter, &title_utf8) || 221 if (!data.ReadString(&iter, &title_utf8) ||
222 !data.ReadString(&iter, &url_utf8)) { 222 !data.ReadString(&iter, &url_utf8)) {
223 return false; 223 return false;
224 } 224 }
225 225
226 GURL gurl(url_utf8); 226 GURL gurl(url_utf8);
227 if (!gurl.is_valid()) 227 if (!gurl.is_valid())
228 return false; 228 return false;
229 229
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 GURL gurl(data.substr(0, newline)); 266 GURL gurl(data.substr(0, newline));
267 if (!gurl.is_valid()) 267 if (!gurl.is_valid())
268 return false; 268 return false;
269 269
270 *url = gurl; 270 *url = gurl;
271 *title = UTF8ToUTF16(data.substr(newline + 1)); 271 *title = UTF8ToUTF16(data.substr(newline + 1));
272 return true; 272 return true;
273 } 273 }
274 274
275 } // namespace ui 275 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/custom_data_helper.cc ('k') | ui/base/dragdrop/os_exchange_data_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698