sql: Switch from custom macro to COMPONENT_EXPORT.

TBR: jsbell
Change-Id: I5b998afa31810577e0bfd9d4d29ef9d462bce5b7
Reviewed-on: https://chromium-review.googlesource.com/c/1390332
Reviewed-by: Victor Costan <[email protected]>
Commit-Queue: Victor Costan <[email protected]>
Cr-Commit-Position: refs/heads/master@{#618989}
diff --git a/sql/BUILD.gn b/sql/BUILD.gn
index 0a220ec..3cfe156 100644
--- a/sql/BUILD.gn
+++ b/sql/BUILD.gn
@@ -20,7 +20,6 @@
     "meta_table.h",
     "recovery.cc",
     "recovery.h",
-    "sql_export.h",
     "sql_features.cc",
     "sql_features.h",
     "sql_memory_dump_provider.cc",
@@ -35,7 +34,7 @@
     "vfs_wrapper.h",
   ]
 
-  defines = [ "SQL_IMPLEMENTATION" ]
+  defines = [ "IS_SQL_IMPL" ]
 
   deps = [
     "//base",
diff --git a/sql/database.h b/sql/database.h
index e4f38ab..f4b6b29 100644
--- a/sql/database.h
+++ b/sql/database.h
@@ -15,6 +15,7 @@
 
 #include "base/callback.h"
 #include "base/compiler_specific.h"
+#include "base/component_export.h"
 #include "base/containers/flat_map.h"
 #include "base/gtest_prod_util.h"
 #include "base/macros.h"
@@ -24,7 +25,6 @@
 #include "base/threading/thread_restrictions.h"
 #include "base/time/tick_clock.h"
 #include "sql/internal_api_token.h"
-#include "sql/sql_export.h"
 #include "sql/statement_id.h"
 
 struct sqlite3;
@@ -64,7 +64,7 @@
 // TODO(pwnall): This should be renamed to Database. Class instances are
 // typically named "db_" / "db", and the class' equivalents in other systems
 // used by Chrome are named LevelDB::DB and blink::IDBDatabase.
-class SQL_EXPORT Database {
+class COMPONENT_EXPORT(SQL) Database {
  private:
   class StatementRef;  // Forward declaration, see real one below.
 
@@ -583,7 +583,8 @@
   //
   // The Database may revoke a StatementRef in some error cases, so callers
   // should always check validity before using.
-  class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> {
+  class COMPONENT_EXPORT(SQL) StatementRef
+      : public base::RefCounted<StatementRef> {
    public:
     REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
 
diff --git a/sql/error_delegate_util.h b/sql/error_delegate_util.h
index 4213321..b0c2ec78 100644
--- a/sql/error_delegate_util.h
+++ b/sql/error_delegate_util.h
@@ -7,14 +7,14 @@
 
 #include <string>
 
+#include "base/component_export.h"
 #include "base/files/file_path.h"
-#include "sql/sql_export.h"
 
 namespace sql {
 
 // Returns true if it is highly unlikely that the database can recover from
 // |error|.
-SQL_EXPORT bool IsErrorCatastrophic(int error);
+COMPONENT_EXPORT(SQL) bool IsErrorCatastrophic(int error);
 
 // Gets diagnostic info of the given |corrupted_file_path| that can be appended
 // to a corrupt database diagnostics info. The file info are not localized as
@@ -22,7 +22,8 @@
 // Also the full file path is not appended as it might contain some PII. Instead
 // only the last two components of the path are appended to distinguish between
 // default and user profiles.
-SQL_EXPORT std::string GetCorruptFileDiagnosticsInfo(
+COMPONENT_EXPORT(SQL)
+std::string GetCorruptFileDiagnosticsInfo(
     const base::FilePath& corrupted_file_path);
 
 }  // namespace sql
diff --git a/sql/initialization.h b/sql/initialization.h
index 98a625a..01eca433 100644
--- a/sql/initialization.h
+++ b/sql/initialization.h
@@ -5,7 +5,7 @@
 #ifndef SQL_INITIALIZATION_H_
 #define SQL_INITIALIZATION_H_
 
-#include "sql/sql_export.h"
+#include "base/component_export.h"
 
 namespace sql {
 
@@ -16,7 +16,7 @@
 //
 // The function is exposed for other components that use SQLite indirectly, such
 // as Blink.
-SQL_EXPORT void EnsureSqliteInitialized();
+COMPONENT_EXPORT(SQL) void EnsureSqliteInitialized();
 
 }  // namespace sql
 
diff --git a/sql/meta_table.h b/sql/meta_table.h
index 0ce66de..9b4acfe 100644
--- a/sql/meta_table.h
+++ b/sql/meta_table.h
@@ -8,8 +8,8 @@
 #include <stdint.h>
 #include <string>
 
+#include "base/component_export.h"
 #include "base/macros.h"
-#include "sql/sql_export.h"
 
 namespace sql {
 
@@ -22,7 +22,7 @@
 // * Helper methods to assist in database schema version control.
 // * Historical data on past attempts to mmap the database to make it possible
 //   to avoid unconditionally retrying to load broken databases.
-class SQL_EXPORT MetaTable {
+class COMPONENT_EXPORT(SQL) MetaTable {
  public:
   MetaTable();
   ~MetaTable();
diff --git a/sql/recovery.h b/sql/recovery.h
index 69dd092..aaaf780 100644
--- a/sql/recovery.h
+++ b/sql/recovery.h
@@ -9,6 +9,7 @@
 
 #include <memory>
 
+#include "base/component_export.h"
 #include "base/macros.h"
 #include "sql/database.h"
 
@@ -62,7 +63,7 @@
 // If Recovered() is not called, then RazeAndClose() is called on
 // orig_db.
 
-class SQL_EXPORT Recovery {
+class COMPONENT_EXPORT(SQL) Recovery {
  public:
   ~Recovery();
 
diff --git a/sql/sql_export.h b/sql/sql_export.h
deleted file mode 100644
index 165120c..0000000
--- a/sql/sql_export.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SQL_SQL_EXPORT_H_
-#define SQL_SQL_EXPORT_H_
-
-#if defined(COMPONENT_BUILD)
-#if defined(WIN32)
-
-#if defined(SQL_IMPLEMENTATION)
-#define SQL_EXPORT __declspec(dllexport)
-#else
-#define SQL_EXPORT __declspec(dllimport)
-#endif  // defined(SQL_IMPLEMENTATION)
-
-#else // defined(WIN32)
-#if defined(SQL_IMPLEMENTATION)
-#define SQL_EXPORT __attribute__((visibility("default")))
-#else
-#define SQL_EXPORT
-#endif
-#endif
-
-#else // defined(COMPONENT_BUILD)
-#define SQL_EXPORT
-#endif
-
-#endif  // SQL_SQL_EXPORT_H_
diff --git a/sql/sql_features.h b/sql/sql_features.h
index 4b0c947..1969727 100644
--- a/sql/sql_features.h
+++ b/sql/sql_features.h
@@ -5,14 +5,14 @@
 #ifndef SQL_SQL_FEATURES_H_
 #define SQL_SQL_FEATURES_H_
 
+#include "base/component_export.h"
 #include "base/feature_list.h"
-#include "sql/sql_export.h"
 
 namespace sql {
 
 namespace features {
 
-SQL_EXPORT extern const base::Feature kSqlTempStoreMemory;
+COMPONENT_EXPORT(SQL) extern const base::Feature kSqlTempStoreMemory;
 
 }  // namespace features
 
diff --git a/sql/sql_memory_dump_provider.h b/sql/sql_memory_dump_provider.h
index f6213bf..57e88c6 100644
--- a/sql/sql_memory_dump_provider.h
+++ b/sql/sql_memory_dump_provider.h
@@ -5,16 +5,16 @@
 #ifndef SQL_SQL_MEMORY_DUMP_PROVIDER_H
 #define SQL_SQL_MEMORY_DUMP_PROVIDER_H
 
+#include "base/component_export.h"
 #include "base/macros.h"
 #include "base/memory/singleton.h"
 #include "base/trace_event/memory_dump_provider.h"
-#include "sql/sql_export.h"
 
 namespace sql {
 
 // Adds process-wide memory usage statistics about sqlite to chrome://tracing.
 // sql::Database::OnMemoryDump adds per-connection memory statistics.
-class SQL_EXPORT SqlMemoryDumpProvider
+class COMPONENT_EXPORT(SQL) SqlMemoryDumpProvider
     : public base::trace_event::MemoryDumpProvider {
  public:
   static SqlMemoryDumpProvider* GetInstance();
diff --git a/sql/statement.h b/sql/statement.h
index cdef13f..ade63a59 100644
--- a/sql/statement.h
+++ b/sql/statement.h
@@ -9,12 +9,12 @@
 #include <string>
 #include <vector>
 
+#include "base/component_export.h"
 #include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/sequence_checker.h"
 #include "base/strings/string16.h"
 #include "sql/database.h"
-#include "sql/sql_export.h"
 
 namespace sql {
 
@@ -43,7 +43,7 @@
 // Step() and Run() just return true to signal success. If you want to handle
 // specific errors such as database corruption, install an error handler in
 // in the connection object using set_error_delegate().
-class SQL_EXPORT Statement {
+class COMPONENT_EXPORT(SQL) Statement {
  public:
   // Creates an uninitialized statement. The statement will be invalid until
   // you initialize it via Assign.
diff --git a/sql/statement_id.h b/sql/statement_id.h
index f52b725d..ee5a90e 100644
--- a/sql/statement_id.h
+++ b/sql/statement_id.h
@@ -7,7 +7,7 @@
 
 #include <cstddef>
 
-#include "sql/sql_export.h"
+#include "base/component_export.h"
 
 namespace sql {
 
@@ -18,7 +18,7 @@
 //
 // StatementID instances should be constructed by using the SQL_FROM_HERE
 // macro, which produces an unique ID based on the source file name and line.
-class SQL_EXPORT StatementID {
+class COMPONENT_EXPORT(SQL) StatementID {
  public:
   // Creates an ID representing a line in the source tree.
   //
diff --git a/sql/transaction.h b/sql/transaction.h
index 3c01a1e6..0b9af69f 100644
--- a/sql/transaction.h
+++ b/sql/transaction.h
@@ -5,14 +5,14 @@
 #ifndef SQL_TRANSACTION_H_
 #define SQL_TRANSACTION_H_
 
+#include "base/component_export.h"
 #include "base/macros.h"
-#include "sql/sql_export.h"
 
 namespace sql {
 
 class Database;
 
-class SQL_EXPORT Transaction {
+class COMPONENT_EXPORT(SQL) Transaction {
  public:
   // Creates the scoped transaction object. You MUST call Begin() to begin the
   // transaction. If you have begun a transaction and not committed it, the