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

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_writer.cc

Issue 126103003: Changed RefCountedStaticMemory() to accept a void pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 10 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 (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 "chrome/browser/bookmarks/bookmark_html_writer.h" 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (!value.GetString(BookmarkCodec::kURLKey, &url_string)) { 260 if (!value.GetString(BookmarkCodec::kURLKey, &url_string)) {
261 NOTREACHED(); 261 NOTREACHED();
262 return false; 262 return false;
263 } 263 }
264 264
265 std::string favicon_string; 265 std::string favicon_string;
266 BookmarkFaviconFetcher::URLFaviconMap::iterator itr = 266 BookmarkFaviconFetcher::URLFaviconMap::iterator itr =
267 favicons_map_->find(url_string); 267 favicons_map_->find(url_string);
268 if (itr != favicons_map_->end()) { 268 if (itr != favicons_map_->end()) {
269 scoped_refptr<base::RefCountedMemory> data(itr->second.get()); 269 scoped_refptr<base::RefCountedMemory> data(itr->second.get());
270 std::string favicon_data;
271 favicon_data.assign(reinterpret_cast<const char*>(data->front()),
272 data->size());
273 std::string favicon_base64_encoded; 270 std::string favicon_base64_encoded;
274 base::Base64Encode(favicon_data, &favicon_base64_encoded); 271 base::Base64Encode(std::string(data->front_as<char>(), data->size()),
272 &favicon_base64_encoded);
275 GURL favicon_url("data:image/png;base64," + favicon_base64_encoded); 273 GURL favicon_url("data:image/png;base64," + favicon_base64_encoded);
276 favicon_string = favicon_url.spec(); 274 favicon_string = favicon_url.spec();
277 } 275 }
278 276
279 if (!WriteIndent() || 277 if (!WriteIndent() ||
280 !Write(kBookmarkStart) || 278 !Write(kBookmarkStart) ||
281 !Write(url_string, ATTRIBUTE_VALUE) || 279 !Write(url_string, ATTRIBUTE_VALUE) ||
282 !Write(kAddDate) || 280 !Write(kAddDate) ||
283 !WriteTime(date_added_string) || 281 !WriteTime(date_added_string) ||
284 (!favicon_string.empty() && 282 (!favicon_string.empty() &&
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // BookmarkModel isn't thread safe (nor would we want to lock it down 501 // BookmarkModel isn't thread safe (nor would we want to lock it down
504 // for the duration of the write), as such we make a copy of the 502 // for the duration of the write), as such we make a copy of the
505 // BookmarkModel using BookmarkCodec then write from that. 503 // BookmarkModel using BookmarkCodec then write from that.
506 if (fetcher == NULL) { 504 if (fetcher == NULL) {
507 fetcher = new BookmarkFaviconFetcher(profile, path, observer); 505 fetcher = new BookmarkFaviconFetcher(profile, path, observer);
508 fetcher->ExportBookmarks(); 506 fetcher->ExportBookmarks();
509 } 507 }
510 } 508 }
511 509
512 } // namespace bookmark_html_writer 510 } // namespace bookmark_html_writer
OLDNEW
« no previous file with comments | « chrome/browser/android/dev_tools_server.cc ('k') | chrome/browser/devtools/browser_list_tabcontents_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698