e8427ebde741b96654865796429b4b5c292e8494
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 2014 Samsung Electronics. 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 FAVICON_DATABASE_P_H
6 #define FAVICON_DATABASE_P_H
7
8 #include <map>
9 #include <queue>
10 #include "url/gurl.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/sqlite/sqlite3.h"
13 #include "base/files/file_path.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/lock.h"
16 #include "base/timer/timer.h"
17 #include "base/memory/weak_ptr.h"
18 #include "content/public/browser/browser_thread.h"
19 #include "favicon_database.h"
20 #include "private/ewk_main_private.h"
21
22 class Command;
23
24 struct FaviconDatabasePrivate : public base::RefCountedThreadSafe<FaviconDatabasePrivate> {
25   FaviconDatabasePrivate();
26
27   GURL faviconUrlForPageUrl(const GURL &pageUrl) const;
28   SkBitmap bitmapForFaviconUrl(const GURL &faviconUrl) const;
29
30   bool existsForFaviconURL(const GURL &faviconUrl) const;
31
32   scoped_refptr<base::SingleThreadTaskRunner> taskRunner() const;
33   void performSync();
34
35   std::map<GURL, GURL> pageToFaviconUrl;
36   std::map<GURL, SkBitmap> faviconUrlToBitmap;
37   base::FilePath path;
38   bool privateBrowsing;
39
40   sqlite3 *sqlite;
41   base::Lock mutex;
42   base::RepeatingTimer timer;
43   std::queue<Command *> commands;
44   base::WeakPtrFactory<FaviconDatabasePrivate> weakPtrFactory;
45
46   static const char * const pageUrlToFaviconUrlTable;
47   static const char * const faviconUrlToBitmapTable;
48   static const char * const pageUrlColumn;
49   static const char * const faviconUrlColumn;
50   static const char * const bitmapColumn;
51   static const char * const defaultDirSuffix;
52   static const char * const defaultFilename;
53
54  private:
55   friend class base::RefCountedThreadSafe<FaviconDatabasePrivate>;
56   ~FaviconDatabasePrivate();
57 };
58
59 #endif // FAVICON_DATABASE_P_H