OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 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 CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ | |
6 #define CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "content/browser/host_zoom_map_impl.h" | |
12 #include "content/public/browser/zoom_level_delegate.h" | |
13 | |
14 class PrefService; | |
15 | |
16 namespace base { | |
17 class FilePath; | |
18 } | |
19 | |
20 namespace content { | |
21 struct HostZoomLevelContextDeleter; | |
22 | |
23 // This class manages a HostZoomMap and, associates it with a PrefsStore, | |
24 // if one is provided. It also serves to keep the zoom level machinery details | |
25 // deparate from the owning StoragePartitionImpl. | |
26 class HostZoomLevelContext | |
27 : public base::RefCountedThreadSafe<HostZoomLevelContext, | |
28 HostZoomLevelContextDeleter> { | |
Fady Samuel
2014/11/03 22:11:11
Is the HostZoomLevelContextDeleter necessary?
wjmaclean
2014/11/04 19:34:25
After a quick experiment, apparently no! Good to k
| |
29 public: | |
30 HostZoomLevelContext(scoped_ptr<ZoomLevelDelegate> zoom_level_delegate, | |
31 const base::FilePath& file_path); | |
32 | |
33 HostZoomMap* GetHostZoomMap() const { return host_zoom_map_impl_.get(); } | |
34 ZoomLevelDelegate* GetZoomLevelDelegate() const { | |
35 return zoom_level_delegate_.get(); | |
36 } | |
37 | |
38 protected: | |
39 virtual ~HostZoomLevelContext(); | |
40 | |
41 private: | |
42 friend class base::DeleteHelper<HostZoomLevelContext>; | |
43 friend class base::RefCountedThreadSafe<HostZoomLevelContext, | |
44 HostZoomLevelContextDeleter>; | |
45 friend struct HostZoomLevelContextDeleter; | |
46 | |
47 void DeleteOnCorrectThread() const; | |
48 | |
49 scoped_ptr<HostZoomMapImpl> host_zoom_map_impl_; | |
50 // The prefs_store pointer needs to be released before the destructor for the | |
wjmaclean
2014/11/03 22:11:06
This comment is stale, I'll remove it in the next
Fady Samuel
2014/11/03 22:11:11
nit: don't mention prefs in content.
| |
51 // HostZoomMapImpl is called, and so must be declared in this order. | |
52 scoped_ptr<ZoomLevelDelegate> zoom_level_delegate_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(HostZoomLevelContext); | |
55 }; | |
56 | |
57 struct HostZoomLevelContextDeleter { | |
58 static void Destruct(const HostZoomLevelContext* context) { | |
59 context->DeleteOnCorrectThread(); | |
60 } | |
61 }; | |
62 | |
63 } // namespace content | |
64 | |
65 #endif // CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ | |
OLD | NEW |