Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 
 
Charlie Reis
2014/11/11 05:29:22
nit: No (c)
 
wjmaclean
2014/11/11 19:20:52
Done. (I thought I had cleaned all those up ... oh
 
 | |
| 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; | |
| 
 
Charlie Reis
2014/11/11 05:29:22
Looks unnecessary.
 
wjmaclean
2014/11/11 19:20:52
Done. (Similarly, thought I had removed this too .
 
 | |
| 18 } | |
| 19 | |
| 20 namespace content { | |
| 21 struct HostZoomLevelContextDeleter; | |
| 22 | |
| 23 // This class manages a HostZoomMap and associates it with a ZoomLevelDelegate, | |
| 24 // if one is provided. It also serves to keep the zoom level machinery details | |
| 25 // separate from the owning StoragePartitionImpl. | |
| 26 class HostZoomLevelContext | |
| 27 : public base::RefCountedThreadSafe<HostZoomLevelContext, | |
| 28 HostZoomLevelContextDeleter> { | |
| 29 public: | |
| 30 explicit HostZoomLevelContext( | |
| 31 scoped_ptr<ZoomLevelDelegate> zoom_level_delegate); | |
| 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 // Release the delegate before the HostZoomMap, in case it is carrying | |
| 51 // any HostZoomMap::Subscription pointers. | |
| 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 |