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 <[email protected]>
Reviewed-by: Chris Mumford <[email protected]>
Cr-Commit-Position: refs/heads/master@{#575876}
diff --git a/sql/connection.cc b/sql/connection.cc
index e3305779..25691db5 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -1435,7 +1435,7 @@
 
   // Return inactive statement.
   if (!db_)
-    return new StatementRef(NULL, NULL, poisoned_);
+    return base::MakeRefCounted<StatementRef>(nullptr, nullptr, poisoned_);
 
   sqlite3_stmt* stmt = NULL;
   int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL);
@@ -1445,9 +1445,9 @@
 
     // It could also be database corruption.
     OnSqliteError(rc, NULL, sql);
-    return new StatementRef(NULL, NULL, false);
+    return base::MakeRefCounted<StatementRef>(nullptr, nullptr, false);
   }
-  return new StatementRef(tracking_db, stmt, true);
+  return base::MakeRefCounted<StatementRef>(tracking_db, stmt, true);
 }
 
 scoped_refptr<Connection::StatementRef> Connection::GetUntrackedStatement(