Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Unified Diff: content/browser/media_gallery/media_gallery_database.h

Issue 9567035: Added MediaGalleryDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix windows compile Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/media_gallery/media_gallery_database.h
diff --git a/content/browser/media_gallery/media_gallery_database.h b/content/browser/media_gallery/media_gallery_database.h
new file mode 100644
index 0000000000000000000000000000000000000000..2dd11a395b21a4db812ec8fe34d2494c57ea201d
--- /dev/null
+++ b/content/browser/media_gallery/media_gallery_database.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2012 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 CONTENT_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_DATABASE_H_
+#define CONTENT_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_DATABASE_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "content/browser/media_gallery/media_gallery_types.h"
+#include "content/common/content_export.h"
+#include "sql/connection.h"
+#include "sql/init_status.h"
+#include "sql/meta_table.h"
+
+namespace media_gallery {
+
+class CONTENT_EXPORT MediaGalleryDatabase {
+ public:
+ MediaGalleryDatabase();
+ virtual ~MediaGalleryDatabase();
+
+ // Must call this function to complete initialization. Will return true on
+ // success. On false, no other function should be called.
+ sql::InitStatus Init(const FilePath& database_path);
+
+ // Returns the current version that we will generate history databases with.
Lei Zhang 2012/03/07 01:41:42 history -> media gallery.
tpayne 2012/03/07 18:04:03 Done.
+ static int GetCurrentVersion();
+
+ // Sets the id_ field of the input collection_row to the generated unique
Lei Zhang 2012/03/07 01:41:42 id_ -> id
tpayne 2012/03/07 18:04:03 Done.
+ // key value and returns the same. On failure, returns zero.
Lei Zhang 2012/03/07 01:41:42 What does it return on success?
tpayne 2012/03/07 18:04:03 The new value of row->id. See "and returns the sam
+ int CreateCollectionRow(CollectionRow* collection_row);
+
+ // Finds the row with the specified id and fills its data into the collection
+ // pointer passed by the caller. Returns true on success.
+ bool GetCollectionRow(CollectionId id, CollectionRow* collection);
+
+ protected:
+ virtual sql::Connection& GetDB();
+
+ // Initializes an already open database.
+ sql::InitStatus InitInternal(sql::Connection* db);
+ static bool DoesCollectionsTableExist(sql::Connection* db);
+
+ private:
+ sql::Connection db_;
Lei Zhang 2012/03/07 01:41:42 Methods before data members.
tpayne 2012/03/07 18:04:03 Done.
+ sql::MetaTable meta_table_;
+ static bool CreateCollectionsTable(sql::Connection* db);
+ sql::InitStatus EnsureCurrentVersion();
+ void FillCollectionRow(const sql::Statement& s, CollectionRow* i);
+
+ DISALLOW_COPY_AND_ASSIGN(MediaGalleryDatabase);
+};
+
+} // namespace media_gallery
+
+std::ostream& operator<<(std::ostream& out,
+ const media_gallery::CollectionRow& row);
+
+#endif // CONTENT_BROWSER_MEDIA_GALLERY_MEDIA_GALLERY_DATABASE_H_

Powered by Google App Engine
This is Rietveld 408576698