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

Side by Side Diff: components/search_engines/keyword_table.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 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 | « components/proximity_auth/client.cc ('k') | components/search_provider_logos/logo_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/search_engines/keyword_table.h" 5 #include "components/search_engines/keyword_table.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 int id_column, 93 int id_column,
94 int starting_column) { 94 int starting_column) {
95 // Serialize |alternate_urls| to JSON. 95 // Serialize |alternate_urls| to JSON.
96 // TODO(beaudoin): Check what it would take to use a new table to store 96 // TODO(beaudoin): Check what it would take to use a new table to store
97 // alternate_urls while keeping backups and table signature in a good state. 97 // alternate_urls while keeping backups and table signature in a good state.
98 // See: crbug.com/153520 98 // See: crbug.com/153520
99 base::ListValue alternate_urls_value; 99 base::ListValue alternate_urls_value;
100 for (size_t i = 0; i < data.alternate_urls.size(); ++i) 100 for (size_t i = 0; i < data.alternate_urls.size(); ++i)
101 alternate_urls_value.AppendString(data.alternate_urls[i]); 101 alternate_urls_value.AppendString(data.alternate_urls[i]);
102 std::string alternate_urls; 102 std::string alternate_urls;
103 base::JSONWriter::Write(&alternate_urls_value, &alternate_urls); 103 base::JSONWriter::Write(alternate_urls_value, &alternate_urls);
104 104
105 s->BindInt64(id_column, data.id); 105 s->BindInt64(id_column, data.id);
106 s->BindString16(starting_column, data.short_name()); 106 s->BindString16(starting_column, data.short_name());
107 s->BindString16(starting_column + 1, data.keyword()); 107 s->BindString16(starting_column + 1, data.keyword());
108 s->BindString(starting_column + 2, data.favicon_url.is_valid() ? 108 s->BindString(starting_column + 2, data.favicon_url.is_valid() ?
109 history::URLDatabase::GURLToDatabaseURL(data.favicon_url) : 109 history::URLDatabase::GURLToDatabaseURL(data.favicon_url) :
110 std::string()); 110 std::string());
111 s->BindString(starting_column + 3, data.url()); 111 s->BindString(starting_column + 3, data.url());
112 s->BindBool(starting_column + 4, data.safe_for_autoreplace); 112 s->BindBool(starting_column + 4, data.safe_for_autoreplace);
113 s->BindString(starting_column + 5, data.originating_url.is_valid() ? 113 s->BindString(starting_column + 5, data.originating_url.is_valid() ?
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 } 474 }
475 475
476 // Replace the old table with the new one. 476 // Replace the old table with the new one.
477 sql = "DROP TABLE " + name; 477 sql = "DROP TABLE " + name;
478 if (!db_->Execute(sql.c_str())) 478 if (!db_->Execute(sql.c_str()))
479 return false; 479 return false;
480 sql = "ALTER TABLE keywords_temp RENAME TO " + name; 480 sql = "ALTER TABLE keywords_temp RENAME TO " + name;
481 return db_->Execute(sql.c_str()); 481 return db_->Execute(sql.c_str());
482 } 482 }
OLDNEW
« no previous file with comments | « components/proximity_auth/client.cc ('k') | components/search_provider_logos/logo_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698