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

Unified Diff: chrome/utility/importer/edge_database_reader_win.h

Issue 1465853002: Implement support for importing favorites from Edge on Windows 10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing include files Created 5 years 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: chrome/utility/importer/edge_database_reader_win.h
diff --git a/chrome/utility/importer/edge_database_reader_win.h b/chrome/utility/importer/edge_database_reader_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b87801358b637fef6d2d99cf59adacf261d6bb9
--- /dev/null
+++ b/chrome/utility/importer/edge_database_reader_win.h
@@ -0,0 +1,95 @@
+// Copyright 2015 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 CHROME_UTILITY_IMPORTER_EDGE_DATABASE_READER_WIN_H_
+#define CHROME_UTILITY_IMPORTER_EDGE_DATABASE_READER_WIN_H_
+
+#define JET_UNICODE
+#include <esent.h>
+#undef JET_UNICODE
+
+#include <map>
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/strings/string16.h"
+
+class EdgeErrorObject {
+ public:
+ EdgeErrorObject() : last_error_(JET_errSuccess) {}
+
+ // Get the last error converted to a descriptive string.
+ base::string16 GetErrorMessage() const;
+ // Get the last error value.
+ JET_ERR last_error() const { return last_error_; }
+
+ protected:
+ // This function returns true if the passed error parameter is equal
+ // to JET_errSuccess
+ bool SetLastError(JET_ERR error);
+
+ private:
+ JET_ERR last_error_;
+
+ DISALLOW_COPY_AND_ASSIGN(EdgeErrorObject);
+};
+
+class EdgeDatabaseTableEnumerator : public EdgeErrorObject {
+ public:
+ EdgeDatabaseTableEnumerator(const base::string16& table_name,
+ JET_SESID session_id,
+ JET_TABLEID table_id);
+
+ ~EdgeDatabaseTableEnumerator();
+
+ const base::string16& table_name() { return table_name_; }
+
+ // Reset the enumerator to the start of the table. Returns true if successful.
+ bool Reset();
+ // Move to the next row in the table. Returns false on error or no more rows.
+ bool Next();
+
+ // Retrieve a column's data value. If a NULL is encountered in the column the
+ // default value for the template type is placed in |value|.
+ template <typename T>
+ bool RetrieveColumn(const base::string16& column_name, T* value);
+
+ private:
+ const JET_COLUMNBASE& GetColumnByName(const base::string16& column_name);
+
+ std::map<const base::string16, JET_COLUMNBASE> columns_by_name_;
+ JET_TABLEID table_id_;
+ base::string16 table_name_;
+ JET_SESID session_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(EdgeDatabaseTableEnumerator);
+};
+
+class EdgeDatabaseReader : public EdgeErrorObject {
+ public:
+ EdgeDatabaseReader()
+ : db_id_(JET_dbidNil),
+ instance_id_(JET_instanceNil),
+ session_id_(JET_sesidNil) {}
+
+ ~EdgeDatabaseReader();
+
+ // Open the database from a file path. Returns true on success.
+ bool OpenDatabase(const base::string16& database_file);
+
+ // Open a row enumerator for a specified table. Returns a nullptr on error.
+ scoped_ptr<EdgeDatabaseTableEnumerator> OpenTableEnumerator(
+ const base::string16& table_name);
+
+ private:
+ bool IsOpen() { return instance_id_ != JET_instanceNil; }
+
+ JET_DBID db_id_;
+ JET_INSTANCE instance_id_;
+ JET_SESID session_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(EdgeDatabaseReader);
+};
+
+#endif // CHROME_UTILITY_IMPORTER_EDGE_DATABASE_READER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698