OLD | NEW |
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 "components/history/core/browser/android/android_urls_database.h" | 5 #include "components/history/core/browser/android/android_urls_database.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "sql/connection.h" | 10 #include "sql/connection.h" |
9 #include "sql/statement.h" | 11 #include "sql/statement.h" |
10 | 12 |
11 namespace history { | 13 namespace history { |
12 | 14 |
13 AndroidURLsDatabase::AndroidURLsDatabase() { | 15 AndroidURLsDatabase::AndroidURLsDatabase() { |
14 } | 16 } |
15 | 17 |
16 AndroidURLsDatabase::~AndroidURLsDatabase() { | 18 AndroidURLsDatabase::~AndroidURLsDatabase() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 URLID url_id) { | 53 URLID url_id) { |
52 if (GetAndroidURLRow(url_id, NULL)) { | 54 if (GetAndroidURLRow(url_id, NULL)) { |
53 LOG(ERROR) << "url_id already exist"; | 55 LOG(ERROR) << "url_id already exist"; |
54 return 0; | 56 return 0; |
55 } | 57 } |
56 | 58 |
57 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | 59 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, |
58 "INSERT INTO android_urls (raw_url, url_id) VALUES (?, ?)")); | 60 "INSERT INTO android_urls (raw_url, url_id) VALUES (?, ?)")); |
59 | 61 |
60 statement.BindString(0, raw_url); | 62 statement.BindString(0, raw_url); |
61 statement.BindInt64(1, static_cast<int64>(url_id)); | 63 statement.BindInt64(1, static_cast<int64_t>(url_id)); |
62 | 64 |
63 if (!statement.Run()) { | 65 if (!statement.Run()) { |
64 LOG(ERROR) << GetDB().GetErrorMessage(); | 66 LOG(ERROR) << GetDB().GetErrorMessage(); |
65 return 0; | 67 return 0; |
66 } | 68 } |
67 return GetDB().GetLastInsertRowId(); | 69 return GetDB().GetLastInsertRowId(); |
68 } | 70 } |
69 | 71 |
70 bool AndroidURLsDatabase::GetAndroidURLRow(URLID url_id, AndroidURLRow* row) { | 72 bool AndroidURLsDatabase::GetAndroidURLRow(URLID url_id, AndroidURLRow* row) { |
71 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | 73 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 "SELECT id, raw_url, url_id FROM android_urls_tmp")) | 174 "SELECT id, raw_url, url_id FROM android_urls_tmp")) |
173 return false; | 175 return false; |
174 | 176 |
175 if (!GetDB().Execute("DROP TABLE android_urls_tmp")) | 177 if (!GetDB().Execute("DROP TABLE android_urls_tmp")) |
176 return false; | 178 return false; |
177 | 179 |
178 return true; | 180 return true; |
179 } | 181 } |
180 | 182 |
181 } // namespace history | 183 } // namespace history |
OLD | NEW |