OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Maps hostnames to custom zoom levels. Written on the UI thread and read on | 5 // Maps hostnames to custom zoom levels. Written on the UI thread and read on |
6 // any thread. One instance per browser context. | 6 // any thread. One instance per browser context. |
7 | 7 |
8 #ifndef CONTENT_BROWSER_HOST_ZOOM_MAP_H_ | 8 #ifndef CONTENT_BROWSER_HOST_ZOOM_MAP_H_ |
9 #define CONTENT_BROWSER_HOST_ZOOM_MAP_H_ | 9 #define CONTENT_BROWSER_HOST_ZOOM_MAP_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <map> | 12 #include <map> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/message_loop_helpers.h" |
18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
19 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
23 | 24 |
24 // HostZoomMap needs to be deleted on the UI thread because it listens | 25 // HostZoomMap needs to be deleted on the UI thread because it listens |
25 // to notifications on there (and holds a NotificationRegistrar). | 26 // to notifications on there (and holds a NotificationRegistrar). |
26 class CONTENT_EXPORT HostZoomMap | 27 class CONTENT_EXPORT HostZoomMap |
27 : public content::NotificationObserver, | 28 : public content::NotificationObserver, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 double default_zoom_level() const { return default_zoom_level_; } | 73 double default_zoom_level() const { return default_zoom_level_; } |
73 void set_default_zoom_level(double level) { default_zoom_level_ = level; } | 74 void set_default_zoom_level(double level) { default_zoom_level_ = level; } |
74 | 75 |
75 HostZoomMap* GetOriginal() const { return original_; } | 76 HostZoomMap* GetOriginal() const { return original_; } |
76 | 77 |
77 private: | 78 private: |
78 friend class base::RefCountedThreadSafe< | 79 friend class base::RefCountedThreadSafe< |
79 HostZoomMap, content::BrowserThread::DeleteOnUIThread>; | 80 HostZoomMap, content::BrowserThread::DeleteOnUIThread>; |
80 friend struct content::BrowserThread::DeleteOnThread< | 81 friend struct content::BrowserThread::DeleteOnThread< |
81 content::BrowserThread::UI>; | 82 content::BrowserThread::UI>; |
82 friend class DeleteTask<HostZoomMap>; | 83 friend class base::DeleteHelper<HostZoomMap>; |
83 | 84 |
84 typedef std::map<std::string, double> HostZoomLevels; | 85 typedef std::map<std::string, double> HostZoomLevels; |
85 | 86 |
86 virtual ~HostZoomMap(); | 87 virtual ~HostZoomMap(); |
87 void Init(); | 88 void Init(); |
88 | 89 |
89 // Copy of the pref data, so that we can read it on the IO thread. | 90 // Copy of the pref data, so that we can read it on the IO thread. |
90 HostZoomLevels host_zoom_levels_; | 91 HostZoomLevels host_zoom_levels_; |
91 double default_zoom_level_; | 92 double default_zoom_level_; |
92 | 93 |
(...skipping 13 matching lines...) Expand all Loading... |
106 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and | 107 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and |
107 // |temporary_zoom_levels_| to guarantee thread safety. | 108 // |temporary_zoom_levels_| to guarantee thread safety. |
108 mutable base::Lock lock_; | 109 mutable base::Lock lock_; |
109 | 110 |
110 content::NotificationRegistrar registrar_; | 111 content::NotificationRegistrar registrar_; |
111 | 112 |
112 DISALLOW_COPY_AND_ASSIGN(HostZoomMap); | 113 DISALLOW_COPY_AND_ASSIGN(HostZoomMap); |
113 }; | 114 }; |
114 | 115 |
115 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_H_ | 116 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_H_ |
OLD | NEW |