0
Commit Graph

47 Commits

Author SHA1 Message Date
Etienne Bergeron
e7681c70c1 Add location to SQL ScopedBlockingCall
Lift the location into the InitScopedBlockingCall to allow
debugging slow cases with slow-reports.

Bug: 1027929
Change-Id: Ife752fab110d11fac07a0646e0bc2353e9396ff1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003213
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732638}
2020-01-17 00:51:20 +00:00
Jose Dapena Paz
e18b4d30e4 sql: fix GCC build after introducing enum class sql::ColumnType
GCC complains about symbol clash between enum class sql::ColumnType
and method Statement::ColumnType. To avoid this, rename the method
to Statement::GetColumnType.

BUG=chromium:819294

Change-Id: Ic49ba2233ba062be958478c6f659e6b72276457a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1553320
Commit-Queue: José Dapena Paz <jose.dapena@lge.com>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Ben Wells <benwells@chromium.org>
Cr-Commit-Position: refs/heads/master@{#648859}
2019-04-08 20:59:34 +00:00
Victor Costan
57aecd2382 sql: Refactor enum sql::ColType into enum class sql::ColumnType.
Change-Id: If03e290991183b37390592b35d79b9d44f50d623
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1552440
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#647664}
2019-04-04 09:09:57 +00:00
Victor Costan
5e785e3166 sql: Remove some large and mostly unused histograms.
This CL removes two classes of histograms.

1) SQL statement timing distributions, in the histograms below.
   * Sqlite.AutoCommitTime.*
   * Sqlite.CommitTime.*
   * Sqlite.QueryTime.*
   * Sqlite.UpdateTime.*

The timing distributions cover all SQL statements issued by each browser
feature built on top of SQLite, so they collect a large volume of data.
Their usefulness does not measure up to the amount of data collected,
for the reasons below.
* The histograms are too coarse to be useful as feature-level metrics.
  The features whose owners are interested in optimizing performance
  should deploy metrics that are specific to concrete investigations and
  experiments.
* The histograms are less useful as SQLite-level metrics than the
  heartbeat metrics that show overall Chrome performance.

2) Statistics about successful SQL statements and transactions, expressed
   as the following enum values in Sqlite.Stats.*
   * EVENT_STATEMENT_RUN
   * EVENT_STATEMENT_ROWS
   * EVENT_STATEMENT_SUCCESS
   * EVENT_EXECUTE
   * EVENT_CHANGES_AUTOCOMMIT
   * EVENT_CHANGES
   * EVENT_BEGIN
   * EVENT_COMMIT
   * EVENT_ROLLBACK
   * EVENT_MMAP_SUCCESS_NEW
   * EVENT_MMAP_SUCCESS_PARTIAL
   * EVENT_MMAP_SUCCESS_NO_PROGRESS

These statistics cover all SQL statements / transactions used by each
browser features. Like the timing distributions above, they end up
collecting a lot of data, and aren't very useful. Raw SQL statement
counts are at best a very indirect measure of each feature's usage.

This CL removes the success outcomes, but keeps the error outcomes.
The metrics for errors are recorded much less often, as SQL operations
fail rarely, and are sufficient for computing error rates, which are a
bit more actionable.

Bug: 935824
Change-Id: Ia8f8c13a45ba78819bab8f130509cd6a8c6842a7
Reviewed-on: https://chromium-review.googlesource.com/c/1488952
Commit-Queue: Steven Holte <holte@chromium.org>
Auto-Submit: Victor Costan <pwnall@chromium.org>
Reviewed-by: Chris Mumford <cmumford@google.com>
Reviewed-by: Steven Holte <holte@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635668}
2019-02-26 20:39:31 +00:00
Etienne Pierre-Doray
a71d7afa39 [TaskScheduler]: Migrate off of AssertBlockingAllowedDeprecated in /sql
base::AssertBlockingAllowedDeprecated is deprecated in favor of
ScopedBlockingCall, which serves as a precise annotation of
the scope that may/will block.

Please make sure of the following:
  - ScopedBlockingCall is instantiated in a scope with minimal CPU usage.
    If this is not the case, ScopedBlockingCall should be instantiated
    closer to the blocking call. See scoped_blocking_call.h for more
    info. Please let me know when/where the blocking call happens if this needs
    to be changed.
  - Parameter |blocking_type| matches expectation:
      MAY_BLOCK: The call might block (e.g. file I/O that might hit in memory cache).
      WILL_BLOCK: The call will definitely block (e.g. cache already checked and now pinging
        server synchronously).
    See BlockingType for more info. While I assumed MAY_BLOCK by default, that might
    not be the best fit if we know that this callsite is guaranteed to block.
  - The ScopedBlockingCall's scope covers the entirety of the blocking operation
    previously asserted against by the AssertBlockingAllowed().
  - Calls to blocking //base APIs don't need to be annotated
    with ScopedBlockingCall. All blocking //base APIs (e.g. base::ReadFileToString, base::File::Read,
    base::SysInfo::AmountOfFreeDiskSpace, base::WaitableEvent::Wait, etc.) have their
    own internal annotations.

Refer to the top-level CL if necessary :
https://chromium-review.googlesource.com/c/chromium/src/+/1338391

Please CQ if LGTY!

This CL was uploaded by git cl split.

R=cmumford@chromium.org

Bug: 903957
Change-Id: Ia7d71b3bc2536dad0e6adc669aebe36addfd7fd0
Reviewed-on: https://chromium-review.googlesource.com/c/1365805
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Chris Mumford <cmumford@google.com>
Cr-Commit-Position: refs/heads/master@{#629836}
2019-02-07 02:07:54 +00:00
Will Harris
b869359dcc Fix some 64-bit to 32-bit implicit conversions in sql.
Found with -Wshorten-64-to-32.

../../sql/initialization.cc(21,59):  warning: implicit conversion loses integer precision: 'long long' to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
  UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.TenMinutes", used / 1024);
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
../..\base/metrics/histogram_macros.h(364,11):  note: expanded from macro 'UMA_HISTOGRAM_COUNTS'
    name, sample, 1, 1000000, 50)
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../sql/initialization.cc(26,56):  warning: implicit conversion loses integer precision: 'long long' to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
  UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneHour", used / 1024);
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
../..\base/metrics/histogram_macros.h(364,11):  note: expanded from macro 'UMA_HISTOGRAM_COUNTS'
    name, sample, 1, 1000000, 50)
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../sql/initialization.cc(31,55):  warning: implicit conversion loses integer precision: 'long long' to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
  UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneDay", used / 1024);
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
../..\base/metrics/histogram_macros.h(364,11):  note: expanded from macro 'UMA_HISTOGRAM_COUNTS'
    name, sample, 1, 1000000, 50)
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../sql/initialization.cc(36,56):  warning: implicit conversion loses integer precision: 'long long' to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
  UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneWeek", used / 1024);
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
../..\base/metrics/histogram_macros.h(364,11):  note: expanded from macro 'UMA_HISTOGRAM_COUNTS'
    name, sample, 1, 1000000, 50)
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../sql/statement.cc(167,40):  warning: implicit conversion loses integer precision: 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type' (aka 'unsigned long long') to 'int' [-Wshorten-64-to-32]
                                   val.size(), SQLITE_TRANSIENT));
                                   ~~~~^~~~~~

../../sql/database.cc(346,24):  warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
        histogram->Add(sample);
                   ~~~ ^~~~~~

../../sql/database.cc(347,45):  warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
      UMA_HISTOGRAM_COUNTS("Sqlite.SizeKB", sample);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
../..\base/metrics/histogram_macros.h(364,11):  note: expanded from macro 'UMA_HISTOGRAM_COUNTS'
    name, sample, 1, 1000000, 50)
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros.h(189,15):  note: expanded from macro 'UMA_HISTOGRAM_CUSTOM_COUNTS'
        name, sample, min, max, bucket_count,                                  \
        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(128,19):  note: expanded from macro 'INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG'
        name, Add(sample),                                                     \
              ~~~ ^~~~~~
../..\base/metrics/histogram_macros_internal.h(120,27):  note: expanded from macro 'STATIC_HISTOGRAM_POINTER_BLOCK'
                          histogram_add_method_invocation,                     \
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../..\base/metrics/histogram_macros_internal.h(104,24):  note: expanded from macro 'HISTOGRAM_POINTER_USE'
    histogram_pointer->histogram_add_method_invocation;                        \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../sql/database.cc(1810,20):  warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'base::HistogramBase::Sample' (aka 'int') [-Wshorten-64-to-32]
    histogram->Add(sample);
               ~~~ ^~~~~~

BUG=588506

Change-Id: I5b0fb4d1913301a64af178924f98c22e7811b359
Reviewed-on: https://chromium-review.googlesource.com/1188758
Reviewed-by: Victor Costan <pwnall@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586906}
2018-08-28 22:58:44 +00:00
Victor Costan
cfbfa60d86 sql: Rename sql::Connection to sql::Database.
sql::Connection represents an opened SQLite database. Pedantically, the
name is correct. At the same time, it is inconsistent with the naming
convention of similar software -- IndexedDB, LevelDB, and WebSQL all use
a derivative of "Database" (IDBDatabase, DB, WindowDatabase) to name
this concept. Furthermore, most sql::Connection instances have names
like "db" and "database".

This CL renames the class to sql::Database, reducing the cognitive load
caused by dissonances like "sql::Connection db_".

TBR=mpearson

Bug: none
Change-Id: I8abf34016bca236b6e38a772f5848e7ea9bf1c59
Reviewed-on: https://chromium-review.googlesource.com/1157876
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579990}
2018-08-01 23:24:46 +00:00
Victor Costan
3a325b8121 sql: Clean up some checks in sql::Statement.
This CL is extracted from https://crrev.com/c/1137851 because that CL
may uncover brokenness and get reverted. Landing these changes
separately minimizes the impact of a potential revert.

Bug: 863724
Change-Id: I9b8888faf7a736f086ca5e496f85a78e0754a0c5
Reviewed-on: https://chromium-review.googlesource.com/1145837
Reviewed-by: Chris Mumford <cmumford@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577289}
2018-07-23 22:16:18 +00:00
Victor Costan
35b2674541 DOMStorage: Remove support for V1 database schema.
The V2 schema was introduced in WebKit on 2011-07-15, in
https://bugs.webkit.org/show_bug.cgi?id=58762. Removing support for the
V1 schema allows us to remove the plumbing for a SQLite feature that no
other part of the codebase uses.

This CL does mean that a hypothetical user who hasn't upgraded Chrome
for 7 years and suddenly upgrades will have their DOM storage reset. We
generally support database schemas up to 2 years old, so this
hypothetical user will most likely start with a clean slate anyways.

Change-Id: I8e21c525a114ed1da856af5c393d62a0ad8cfb1c
Reviewed-on: https://chromium-review.googlesource.com/1146280
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577266}
2018-07-23 21:26:41 +00:00
Victor Costan
87cf8c72aa sql: Add precondition checks to sql::Connection.
This CL adds DCHECKs covering a few of the preconditions in
sql::Connection's API and removes sql::TimeSource, which duplicates
base::TickClock.

Bug: none
Change-Id: Ia62874ccf339cf2338e388a45a41d789e3ef89e3
Reviewed-on: https://chromium-review.googlesource.com/1143132
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Chris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576589}
2018-07-19 19:36:04 +00:00
Victor Costan
bd62311a9e sql: Replace NULL with nullptr.
Change-Id: Ie3ad5785f82ccafdbcc630a5a26423ecc0b6c4bc
Reviewed-on: https://chromium-review.googlesource.com/1137846
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Chris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575937}
2018-07-18 04:17:27 +00:00
Victor Costan
3b02cdf5fb sql: Make Connection::StatementRef use 1-based ref-counting.
0-based ref-counting is deprecated. 1-based counting is described in
//base/memory/ref_counted.h. In summary, instaces must be created by
base::MakeRefCounted<T> or (less ideal) base::AdoptRef(new T).

This CL switches Connection::StatementRef to 1-based ref-counting, and

std::move()'s scoped_refptr<StatementRef> in a few places where that
avoids refcount churn.

Bug: none
Change-Id: I14755dc2482f18c8a9582066104f346c2873941d
Reviewed-on: https://chromium-review.googlesource.com/1137848
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Chris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575876}
2018-07-18 00:39:56 +00:00
Sigurdur Asgeirsson
8d82bd0b78 Change DLOG(FATAL) to DLOG(DCHECK) in sql/
This is necessary to make these DLOG statments non-fatal in
Albatross builds.

Bug: 596231
Change-Id: I7634aad4eb74f2a0736f9e5775c6198368151c55
Reviewed-on: https://chromium-review.googlesource.com/679254
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504164}
2017-09-25 21:05:52 +00:00
vabr
b194fc5678 Minor fixes in login_database.* and sql/statement.*
This CL fixes a couple of style nits pointed out by lint in login_database.*, and also changes
sql::Statement::ColumnBlobAsString to const.

BUG=413020

Review-Url: https://codereview.chromium.org/2133173003
Cr-Commit-Position: refs/heads/master@{#405089}
2016-07-13 08:49:26 +00:00
avi
0b519209e6 Switch to standard integer types in xxx/.
BUG=138542
TBR=shess@chromium.org

Review URL: https://codereview.chromium.org/1533283002

Cr-Commit-Position: refs/heads/master@{#366346}
2015-12-21 07:26:18 +00:00
shess
7dbd4dee47 [sql] Use memory-mapped I/O for sql::Connection.
sql::Connection::Open*() uses PRAGMA mmap_size to enable SQLite's
memory-mapped I/O.  Additionally instrument to flush dirty pages from
the page cache after writes.

BUG=489784,533682,537681,537636

[Relands https://crrev.com/9a1948a4d6d4 (),
reverted at https://crrev.com/55c3216b15ce (),
relanded at https://crrev.com/5c2f4e50d96d (),
reverted at https://crrev.com/745e18c52384 ().
May the waterfall have mercy on my CL.]

Review URL: https://codereview.chromium.org/1382283003

Cr-Commit-Position: refs/heads/master@{#352631}
2015-10-06 17:39:52 +00:00
zhaoqin
745e18c523 Revert of [sql] Use memory-mapped I/O for sql::Connection. (patchset id:40001 of https://codereview.chromium.org/1368533003/ )
Reason for revert:
data race reported by TSan on sql/connection.cc

BUG=537681

Original issue's description:
> [sql] Use memory-mapped I/O for sql::Connection.
>
> sql::Connection::Open*() uses PRAGMA mmap_size to enable SQLite's
> memory-mapped I/O.  Additionally instrument to flush dirty pages from
> the page cache after writes.
>
> [Relands https://crrev.com/9a1948a4d6d4,
> reverted at https://crrev.com/55c3216b15ce ]
>
> BUG=489784, 533682
>
> Committed: https://crrev.com/5c2f4e50d96d8b2ae0ae4a5c7d319e6be3b33bca
> Cr-Commit-Position: refs/heads/master@{#351344}

TBR=rmcilroy@chromium.org,pavely@chromium.org,shess@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=489784, 533682

Review URL: https://codereview.chromium.org/1375583003

Cr-Commit-Position: refs/heads/master@{#351596}
2015-09-30 18:05:20 +00:00
shess
5c2f4e50d9 [sql] Use memory-mapped I/O for sql::Connection.
sql::Connection::Open*() uses PRAGMA mmap_size to enable SQLite's
memory-mapped I/O.  Additionally instrument to flush dirty pages from
the page cache after writes.

[Relands https://crrev.com/9a1948a4d6d4,
reverted at https://crrev.com/55c3216b15ce ]

BUG=489784, 533682

Review URL: https://codereview.chromium.org/1368533003

Cr-Commit-Position: refs/heads/master@{#351344}
2015-09-29 17:22:02 +00:00
Jeremy Roman
55c3216b15 Revert of [sql] Use memory-mapped I/O for sql::Connection. (patchset id:140001 of https://codereview.chromium.org/1349863003/ )
Reason for revert:
mmap_enabled_ isn't initialized, causing MSAN failures:

https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Linux_MSAN/5882/layout-test-results/virtual/sharedarraybuffer/fast/workers/constructor-proto-crash-log.txt

STDERR: ==3138==WARNING: MemorySanitizer: use-of-uninitialized-value
STDERR:      0x7fc8068d3a65 in ReleaseCacheMemoryIfNeeded sql/connection.cc:513:7
STDERR:      0x7fc8068d3a65 in sql::Connection::ExecuteAndReturnErrorCode(char const*) sql/connection.cc:943:0
STDERR:      0x7fc8068ca454 in sql::Connection::OpenInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sql::Connection::Retry) sql/connection.cc:1275:9
STDERR:      0x7fc8068c845f in sql::Connection::Open(base::FilePath const&) sql/connection.cc:367:10
STDERR:      0x7fc806b1b868 in storage::QuotaDatabase::LazyOpen(bool) storage/browser/quota/quota_database.cc:488:14

Original issue's description:
> [sql] Use memory-mapped I/O for sql::Connection.
>
> sql::Connection::Open*() uses PRAGMA mmap_size to enable SQLite's
> memory-mapped I/O.  Additionally instrument to flush dirty pages from
> the page cache after writes.
>
> BUG=489784,533682
>
> Committed: https://crrev.com/9a1948a4d6d445d5c8e209bdcd1cd050af72060b
> Cr-Commit-Position: refs/heads/master@{#350362}

R=shess@chromium.org
TBR=pavely@chromium.org, pvalenzuela@chromium.org, rmcilroy@chromium.org, shess@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=489784,533682

Review URL: https://codereview.chromium.org/1365783002 .

Cr-Commit-Position: refs/heads/master@{#350386}
2015-09-23 23:28:49 +00:00
shess
9a1948a4d6 [sql] Use memory-mapped I/O for sql::Connection.
sql::Connection::Open*() uses PRAGMA mmap_size to enable SQLite's
memory-mapped I/O.  Additionally instrument to flush dirty pages from
the page cache after writes.

BUG=489784,533682

Review URL: https://codereview.chromium.org/1349863003

Cr-Commit-Position: refs/heads/master@{#350362}
2015-09-23 20:33:56 +00:00
brettw
8e2106dd88 Convert remaining StringToLowerASCII to ToLowerASCII.
Remove StringToLowerASCII. This removes the template and makes a consistent call that can take a string piece.

http_response_headers.cc in HttpResponseHeaders::RemoveHeaderLine there seemed to be a bug where it did
  std::string old_header_name_lowercase(name);
where it actually meant
  std::string old_header_name_lowercase(old_header_name);
I fixed this.

There were a number of cases where url.host() or url.scheme() was passed to ToLowerASCII. These are already guaranteed lower-case, so I removed the call.

There were a number of cases in net that did return ToLowerASCII().c_str() when the return type is a std::string, which is unnecessary and wasteful. I removed the c_str() call.

NOPRESUBMIT=true
(for touching code with wstrings)

Review URL: https://codereview.chromium.org/1282363003

Cr-Commit-Position: refs/heads/master@{#342869}
2015-08-11 19:31:27 +00:00
shess
58b8df8572 [sql] Stats gathering for sql/ APIs.
Generate stats for how many SQL statements are executed, how many
results they return, and how many changes they make.  Generate timing
values for how long is spent doing all queries, doing updating
operations, doing autocommit updates, and commiting transactions.

The goal of these metrics is to quantify results of decisions like
enabling write-ahead log or memory-mapped I/O.

BUG=489788,489444

Review URL: https://codereview.chromium.org/1145833002

Cr-Commit-Position: refs/heads/master@{#332503}
2015-06-03 00:19:59 +00:00
tfarina
720d4f346c sql: Remove basictypes.h includes.
* Use the standard integer types from stdint.h instead.
* Use macros.h for the DISALLOW_COPY_AND_ASSIGN macro.

BUG=138542
TEST=sql_unittests
R=shess@chromium.org

Review URL: https://codereview.chromium.org/1133053004

Cr-Commit-Position: refs/heads/master@{#329256}
2015-05-11 22:31:49 +00:00
mostynb
ddbabe7c05 replace COMPILE_ASSERT with static_assert in sql/
BUG=442514

Review URL: https://codereview.chromium.org/825313002

Cr-Commit-Position: refs/heads/master@{#310006}
2015-01-06 00:21:48 +00:00
brettw@chromium.org
cb1f4ac35e Move StringToLowerASCII to base namespace
TBR=sky

Review URL: https://codereview.chromium.org/448853002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288085 0039d316-1c4b-4281-b951-d872f2087c98
2014-08-07 16:55:42 +00:00
avi@chromium.org
6c3bf03265 Update uses of UTF conversions in ppapi/, printing/, remoting/, rlz/, sandbox/, skia/, sql/, sync/, tools/, webkit/, win8/ to use the base:: namespace.
BUG=330556
TEST=no change
TBR=ben@chromium.org

Review URL: https://codereview.chromium.org/121123002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242502 0039d316-1c4b-4281-b951-d872f2087c98
2013-12-25 19:37:03 +00:00
brettw@chromium.org
fcf75d4016 Convert string16 to base::string16 in content.
BUG=

Review URL: https://codereview.chromium.org/102593002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238447 0039d316-1c4b-4281-b951-d872f2087c98
2013-12-03 20:11:26 +00:00
shess@chromium.org
097723df58 [sql] Complain about statement mutations after stepping has started.
DCHECK if any Bind*() calls occur after Step() has been called.  The
bind cannot be implemented at that point, so most likely the calling
code has an error, such as a forgotted Reset().

Also DCHECK if Run() is called after Run() or Step() without an
intervening Reset().  Such a calling sequence is unlikely to be
intentional, because the results of calling Run() twice aren't
defined.

BUG=309759

Review URL: https://codereview.chromium.org/40733003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231098 0039d316-1c4b-4281-b951-d872f2087c98
2013-10-25 20:09:32 +00:00
shess@chromium.org
2f496b403b [sql] Log tag with sqlite errors.
Log lines like:
ERROR:connection.cc(1007)] sqlite error 266, errno 5: disk I/O error
would be ever so much more useful if they indicated which database
they were associated with.  This logs the histogram tag, which indicates
the logical database (the code which owns this connection).  [As
opposed to the filesystem name.]

BUG=none

Review URL: https://codereview.chromium.org/24638002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225518 0039d316-1c4b-4281-b951-d872f2087c98
2013-09-26 18:36:58 +00:00
avi@chromium.org
a4bbc1f9b8 Use a direct include of strings headers in rlz/, sandbox/, skia/, sql/, sync/.
BUG=247723
TEST=none
TBR=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/16358024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205458 0039d316-1c4b-4281-b951-d872f2087c98
2013-06-11 07:28:19 +00:00
avi@chromium.org
906265870c Use a direct include of utf_string_conversions.h in google_apis/, gpu/, ipc/, media/, ppapi/, printing/, remoting/, rlz/, skia/, sql/, sync/, third_party/, tools/, webkit/, win8/.
BUG=none
TEST=none
TBR=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/15995038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204967 0039d316-1c4b-4281-b951-d872f2087c98
2013-06-07 22:40:45 +00:00
rsleevi@chromium.org
7131880e81 Update sync/, sql/, and printing/ to use scoped_refptr<T>::get() rather than implicit "operator T*"
Linux fixes

BUG=110610
TBR=darin

Review URL: https://chromiumcodereview.appspot.com/16298002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203651 0039d316-1c4b-4281-b951-d872f2087c98
2013-06-03 00:20:05 +00:00
dcheng@chromium.org
007b3f812f Rewrite std::string("") to std::string(), Linux edition.
This patch was generated by running the empty_string clang tool
across the Chromium Linux compilation database. Implicitly or
explicitly constructing std::string() with a "" argument is
inefficient as the caller needs to emit extra instructions to
pass an argument, and the constructor needlessly copies a byte
into internal storage. Rewriting these instances to simply call
the default constructor appears to save ~14-18 kilobytes on an
optimized release build.

BUG=none

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=193020

Review URL: https://codereview.chromium.org/13145003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193040 0039d316-1c4b-4281-b951-d872f2087c98
2013-04-09 08:46:45 +00:00
dcheng@chromium.org
69d7f89d6a Revert "Rewrite std::string("") to std::string(), Linux edition."
This reverts commit e59558b78e.

Revert "Fix build after r193020."

This reverts commit 558a35897f.

Revert "Really fix build after r193020."

This reverts commit e3748a79b5.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193030 0039d316-1c4b-4281-b951-d872f2087c98
2013-04-09 06:41:12 +00:00
dcheng@chromium.org
e59558b78e Rewrite std::string("") to std::string(), Linux edition.
This patch was generated by running the empty_string clang tool
across the Chromium Linux compilation database. Implicitly or
explicitly constructing std::string() with a "" argument is
inefficient as the caller needs to emit extra instructions to
pass an argument, and the constructor needlessly copies a byte
into internal storage. Rewriting these instances to simply call
the default constructor appears to save ~14-18 kilobytes on an
optimized release build.

BUG=none

Review URL: https://codereview.chromium.org/13145003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193020 0039d316-1c4b-4281-b951-d872f2087c98
2013-04-09 05:45:17 +00:00
shess@chromium.org
41a97c81e1 Implement sql::Connection::RazeAndClose().
Raze() clears out the database, but cannot be called within a
transaction.  Close() can only be called once all statements have
cleared.  Error callbacks happen while executing statements (thus
often in a transaction, and at least one statement is outstanding).

RazeAndClose() forcibly breaks outstanding transactions, calls Raze()
to clear the database, then calls Close() to close the handle.  All
future operations against the database should fail safely (without
affecting storage and without crashing).

BUG=166419, 136846


Review URL: https://chromiumcodereview.appspot.com/12096073

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181152 0039d316-1c4b-4281-b951-d872f2087c98
2013-02-07 02:35:38 +00:00
glotov@chromium.org
b4c363bad5 Fixing null pointer dereference.
BUG=chromium:158178
TEST=units,make sure such SEGV doesnt happen on x86-generic-bot (where it pops periodically now)


Review URL: https://chromiumcodereview.appspot.com/11886065

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177399 0039d316-1c4b-4281-b951-d872f2087c98
2013-01-17 13:11:17 +00:00
shess@chromium.org
35f7e5399e Annotate calls to SQLite functions - they have to be executed on a thread allowing IO access.
Also expanded scope of ScopedAllowIO in
SQLiteServerBoundCertStore::Backend::Load() to cover SQLite functions.
And added ScopedAllowIO to PasswordStoreFactory::BuildServiceInstanceFor() --
it calls LoginDatabase::Init() which should be executed on DB thread.

This is a reland of
https://src.chromium.org/viewvc/chrome?view=rev&revision=147309
which was reverted because of missing ScopedAllowIO in PasswordStoreFactory.

Patch from Pavel Ivanov <paivanof@gmail.com>

BUG=75232, 52909, 137961, 138903
TEST=no test fails with message "Function marked as IO-only was called from a thread that disallows IO!"

Review URL: https://chromiumcodereview.appspot.com/10824008
Patch from Pavel Ivanov <paivanof@gmail.com>.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148788 0039d316-1c4b-4281-b951-d872f2087c98
2012-07-27 19:54:50 +00:00
shess@chromium.org
88cb62521e Revert 147309 - Annotate calls to SQLite functions - they have to be executed on a thread allowing IO access.
Expand scope of ScopedAllowIO in the only place where SQLite functions are used on UI thread.

Patch from Pavel Ivanov <paivanof@gmail.com>

BUG=75232,52909,137961
TEST=no test fails with message "Function marked as IO-only was called from a thread that disallows IO!"

Review URL: https://chromiumcodereview.appspot.com/10540155
Patch from Pavel Ivanov <paivanof@gmail.com>.

TBR=shess@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10806025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147340 0039d316-1c4b-4281-b951-d872f2087c98
2012-07-18 23:48:56 +00:00
shess@chromium.org
8262829e7b Annotate calls to SQLite functions - they have to be executed on a thread allowing IO access.
Expand scope of ScopedAllowIO in the only place where SQLite functions are used on UI thread.

Patch from Pavel Ivanov <paivanof@gmail.com>

BUG=75232,52909
TEST=no test fails with message "Function marked as IO-only was called from a thread that disallows IO!"

Review URL: https://chromiumcodereview.appspot.com/10540155
Patch from Pavel Ivanov <paivanof@gmail.com>.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147309 0039d316-1c4b-4281-b951-d872f2087c98
2012-07-18 20:44:26 +00:00
michaelbai@chromium.org
389e0a485f Added parameter 'clear_bound_vars', so we could reset the statement without clearing bound variables, so and current row is reset to the beginning.
It is used to support the Andorid' sqlite cursor feature which could move the cursor around the result set.

BUG=
TEST=Added a new test.
TBR=agl,akalin,michaeln

Review URL: http://codereview.chromium.org/10171014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133985 0039d316-1c4b-4281-b951-d872f2087c98
2012-04-25 21:36:41 +00:00
shess@chromium.org
85fc27b00e Clear statement before closing db in cookie code.
sql::Statement maintains a weak ref to the associated sql::Connection,
meaning that if the database and statement are destructed in the wrong
order, a use-after-free can result.  sql::Statement::Clear() allows
resetting the statement to the default-constructed state.

BUG=111376
TEST=fewer crashes.


Review URL: http://codereview.chromium.org/9418021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122430 0039d316-1c4b-4281-b951-d872f2087c98
2012-02-17 02:15:09 +00:00
benm@chromium.org
c0714dfcce Fix Android build.
Android does not have toLower in it's <algorithm>, use
StringToLowerASCII instead.


Review URL: http://codereview.chromium.org/9384004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121505 0039d316-1c4b-4281-b951-d872f2087c98
2012-02-10 20:19:28 +00:00
benm@chromium.org
98b6f8b1b8 Create a class to represent a Dom Storage Database.
Add a class that can read/write a local storage database in the same format as WebCore's StorageArea.
    
Also add a method to sql::Statement to query the declared type of a column and a method to return a string16 from a Blob.
    
BUG=106763


Review URL: http://codereview.chromium.org/9159020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121442 0039d316-1c4b-4281-b951-d872f2087c98
2012-02-10 13:31:59 +00:00
gbillock@chromium.org
bed29d94d9 Update webdata files to take advantage of DLOG(FATAL) in
sql/Statement and Connection.

R=shess@chromium.org
BUG=
TEST=webdata/*Test*.*


Review URL: http://codereview.chromium.org/8966003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115574 0039d316-1c4b-4281-b951-d872f2087c98
2011-12-22 19:25:51 +00:00
shess@chromium.org
eff1fa525c Put debugging assertions into sql::Statement.
Pulls out the core of gbillock's http://codereview.chromium.org/8283002/
- Move NOTREACHED and similar checks into the sql:: implementation code.
- Add malformed SQL checks to Connection::Execute.
- Add SQL-checking convenience methods to Connection.

The general idea is that the sql:: framework assumes valid statements,
rather than having client code contain scattered ad-hoc (and thus
inconsistent) checks.

This version puts back Statement operator overloading and loosy-goosy
Execute() calls to allow other code to be updated in small batches.

R=gbillock@chromium.org,jhawkins@chromium.org,dhollowa@chromium.org 
BUG=none
TEST=sql_unittests,unit_tests:*Table*.*


Review URL: http://codereview.chromium.org/8899012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114118 0039d316-1c4b-4281-b951-d872f2087c98
2011-12-12 23:50:59 +00:00
tfarina@chromium.org
f0a54b2f3f Move app/sql/* files to sql/ directory.
I can't remove app/app.gyp and app/app_base.gypi yet because they are referenced
by third_party gyp files :(

BUG=72317
TEST=None

R=rsesek@chromium.org

move app/sql to sql

Review URL: http://codereview.chromium.org/7353026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93069 0039d316-1c4b-4281-b951-d872f2087c98
2011-07-19 18:40:21 +00:00