Home | History | Annotate | Download | only in webdata
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_
      6 #define CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_
      7 #pragma once
      8 
      9 #include "app/sql/connection.h"
     10 #include "app/sql/init_status.h"
     11 #include "app/sql/meta_table.h"
     12 
     13 // An abstract base class representing a table within a WebDatabase.
     14 // Each table should subclass this, adding type-specific methods as needed.
     15 class WebDatabaseTable {
     16  protected:
     17   explicit WebDatabaseTable(sql::Connection* db, sql::MetaTable* meta_table)
     18       : db_(db), meta_table_(meta_table) {}
     19   virtual ~WebDatabaseTable() {
     20     db_ = NULL;
     21     meta_table_ = NULL;
     22   };
     23 
     24   // Attempts to initialize the table and returns true if successful.
     25   virtual bool Init() = 0;
     26 
     27   // In order to encourage developers to think about sync when adding or
     28   // or altering new tables, this method must be implemented. Please get in
     29   // contact with the sync team if you believe you're making a change that they
     30   // should be aware of (or if you could break something).
     31   // TODO(andybons): Implement something more robust.
     32   virtual bool IsSyncable() = 0;
     33 
     34   sql::Connection* db_;
     35   sql::MetaTable* meta_table_;
     36 
     37  private:
     38   DISALLOW_COPY_AND_ASSIGN(WebDatabaseTable);
     39 };
     40 
     41 #endif  // CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_
     42