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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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_UTILITY_IMPORTER_EDGE_DATABASE_READER_WIN_H_
6 #define CHROME_UTILITY_IMPORTER_EDGE_DATABASE_READER_WIN_H_
7
8 #define JET_UNICODE
9 #include <esent.h>
10 #undef JET_UNICODE
11
12 #include <map>
13
14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string16.h"
17
18 class EdgeErrorObject {
19 public:
20 EdgeErrorObject() : last_error_(JET_errSuccess) {}
21
22 // Get the last error converted to a descriptive string.
23 base::string16 GetErrorMessage() const;
24 // Get the last error value.
25 JET_ERR last_error() const { return last_error_; }
26
27 protected:
28 // This function returns true if the passed error parameter is equal
29 // to JET_errSuccess
30 bool SetLastError(JET_ERR error);
31
32 private:
33 JET_ERR last_error_;
34
35 DISALLOW_COPY_AND_ASSIGN(EdgeErrorObject);
36 };
37
38 class EdgeDatabaseTableEnumerator : public EdgeErrorObject {
39 public:
40 EdgeDatabaseTableEnumerator(const base::string16& table_name,
41 JET_SESID session_id,
42 JET_TABLEID table_id);
43
44 ~EdgeDatabaseTableEnumerator();
45
46 const base::string16& table_name() { return table_name_; }
47
48 // Reset the enumerator to the start of the table. Returns true if successful.
49 bool Reset();
50 // Move to the next row in the table. Returns false on error or no more rows.
51 bool Next();
52
53 // Retrieve a column's data value. If a NULL is encountered in the column the
54 // default value for the template type is placed in |value|.
55 template <typename T>
56 bool RetrieveColumn(const base::string16& column_name, T* value);
57
58 private:
59 const JET_COLUMNBASE& GetColumnByName(const base::string16& column_name);
60
61 std::map<const base::string16, JET_COLUMNBASE> columns_by_name_;
62 JET_TABLEID table_id_;
63 base::string16 table_name_;
64 JET_SESID session_id_;
65
66 DISALLOW_COPY_AND_ASSIGN(EdgeDatabaseTableEnumerator);
67 };
68
69 class EdgeDatabaseReader : public EdgeErrorObject {
70 public:
71 EdgeDatabaseReader()
72 : db_id_(JET_dbidNil),
73 instance_id_(JET_instanceNil),
74 session_id_(JET_sesidNil) {}
75
76 ~EdgeDatabaseReader();
77
78 // Open the database from a file path. Returns true on success.
79 bool OpenDatabase(const base::string16& database_file);
80
81 // Open a row enumerator for a specified table. Returns a nullptr on error.
82 scoped_ptr<EdgeDatabaseTableEnumerator> OpenTableEnumerator(
83 const base::string16& table_name);
84
85 private:
86 bool IsOpen() { return instance_id_ != JET_instanceNil; }
87
88 JET_DBID db_id_;
89 JET_INSTANCE instance_id_;
90 JET_SESID session_id_;
91
92 DISALLOW_COPY_AND_ASSIGN(EdgeDatabaseReader);
93 };
94
95 #endif // CHROME_UTILITY_IMPORTER_EDGE_DATABASE_READER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698