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, | |
Charlie Reis
2014/11/04 23:43:17
no comma
wjmaclean
2014/11/05 21:55:42
Done.
| |
24 // if one is provided. It also serves to keep the zoom level machinery details | |
25 // deparate from the owning StoragePartitionImpl. | |
Charlie Reis
2014/11/04 23:43:16
separate
wjmaclean
2014/11/05 21:55:42
Done.
| |
26 class HostZoomLevelContext | |
27 : public base::RefCountedThreadSafe<HostZoomLevelContext, | |
28 HostZoomLevelContextDeleter> { | |
29 public: | |
30 HostZoomLevelContext(scoped_ptr<ZoomLevelDelegate> zoom_level_delegate); | |
Charlie Reis
2014/11/04 23:43:16
explicit
wjmaclean
2014/11/05 21:55:42
Done.
| |
31 | |
32 HostZoomMap* GetHostZoomMap() const { return host_zoom_map_impl_.get(); } | |
33 ZoomLevelDelegate* GetZoomLevelDelegate() const { | |
34 return zoom_level_delegate_.get(); | |
35 } | |
36 | |
37 protected: | |
38 virtual ~HostZoomLevelContext(); | |
39 | |
40 private: | |
41 friend class base::DeleteHelper<HostZoomLevelContext>; | |
42 friend class base::RefCountedThreadSafe<HostZoomLevelContext, | |
43 HostZoomLevelContextDeleter>; | |
44 friend struct HostZoomLevelContextDeleter; | |
45 | |
46 void DeleteOnCorrectThread() const; | |
47 | |
48 scoped_ptr<HostZoomMapImpl> host_zoom_map_impl_; | |
49 // Release the delegate before the HostZoomMap, in case it is carrying | |
50 // any HostZoomMap::Subscription pointers. | |
51 scoped_ptr<ZoomLevelDelegate> zoom_level_delegate_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(HostZoomLevelContext); | |
54 }; | |
55 | |
56 struct HostZoomLevelContextDeleter { | |
Charlie Reis
2014/11/04 23:43:17
Generally, "each interface/struct/enum should be i
wjmaclean
2014/11/05 21:55:42
Yes, I modeled this after examples I found elsewhe
| |
57 static void Destruct(const HostZoomLevelContext* context) { | |
58 context->DeleteOnCorrectThread(); | |
59 } | |
60 }; | |
61 | |
62 } // namespace content | |
63 | |
64 #endif // CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ | |
OLD | NEW |