| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ |
| 6 #define CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ | 6 #define CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #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/browser/host_zoom_map_impl.h" |
| 12 #include "content/public/browser/zoom_level_delegate.h" | 13 #include "content/public/browser/zoom_level_delegate.h" |
| 13 | 14 |
| 14 class PrefService; | 15 class PrefService; |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 struct HostZoomLevelContextDeleter; | 18 struct HostZoomLevelContextDeleter; |
| 18 | 19 |
| 19 // This class manages a HostZoomMap and associates it with a ZoomLevelDelegate, | 20 // This class manages a HostZoomMap and associates it with a ZoomLevelDelegate, |
| 20 // if one is provided. It also serves to keep the zoom level machinery details | 21 // if one is provided. It also serves to keep the zoom level machinery details |
| 21 // separate from the owning StoragePartitionImpl. | 22 // separate from the owning StoragePartitionImpl. |
| 22 class HostZoomLevelContext | 23 class HostZoomLevelContext |
| 23 : public base::RefCountedThreadSafe<HostZoomLevelContext, | 24 : public base::RefCountedThreadSafe<HostZoomLevelContext, |
| 24 HostZoomLevelContextDeleter> { | 25 HostZoomLevelContextDeleter> { |
| 25 public: | 26 public: |
| 26 explicit HostZoomLevelContext( | 27 explicit HostZoomLevelContext( |
| 27 scoped_ptr<ZoomLevelDelegate> zoom_level_delegate); | 28 std::unique_ptr<ZoomLevelDelegate> zoom_level_delegate); |
| 28 | 29 |
| 29 HostZoomMap* GetHostZoomMap() const { return host_zoom_map_impl_.get(); } | 30 HostZoomMap* GetHostZoomMap() const { return host_zoom_map_impl_.get(); } |
| 30 ZoomLevelDelegate* GetZoomLevelDelegate() const { | 31 ZoomLevelDelegate* GetZoomLevelDelegate() const { |
| 31 return zoom_level_delegate_.get(); | 32 return zoom_level_delegate_.get(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 protected: | 35 protected: |
| 35 virtual ~HostZoomLevelContext(); | 36 virtual ~HostZoomLevelContext(); |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 friend class base::DeleteHelper<HostZoomLevelContext>; | 39 friend class base::DeleteHelper<HostZoomLevelContext>; |
| 39 friend class base::RefCountedThreadSafe<HostZoomLevelContext, | 40 friend class base::RefCountedThreadSafe<HostZoomLevelContext, |
| 40 HostZoomLevelContextDeleter>; | 41 HostZoomLevelContextDeleter>; |
| 41 friend struct HostZoomLevelContextDeleter; | 42 friend struct HostZoomLevelContextDeleter; |
| 42 | 43 |
| 43 void DeleteOnCorrectThread() const; | 44 void DeleteOnCorrectThread() const; |
| 44 | 45 |
| 45 scoped_ptr<HostZoomMapImpl> host_zoom_map_impl_; | 46 std::unique_ptr<HostZoomMapImpl> host_zoom_map_impl_; |
| 46 // Release the delegate before the HostZoomMap, in case it is carrying | 47 // Release the delegate before the HostZoomMap, in case it is carrying |
| 47 // any HostZoomMap::Subscription pointers. | 48 // any HostZoomMap::Subscription pointers. |
| 48 scoped_ptr<ZoomLevelDelegate> zoom_level_delegate_; | 49 std::unique_ptr<ZoomLevelDelegate> zoom_level_delegate_; |
| 49 | 50 |
| 50 DISALLOW_COPY_AND_ASSIGN(HostZoomLevelContext); | 51 DISALLOW_COPY_AND_ASSIGN(HostZoomLevelContext); |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 struct HostZoomLevelContextDeleter { | 54 struct HostZoomLevelContextDeleter { |
| 54 static void Destruct(const HostZoomLevelContext* context) { | 55 static void Destruct(const HostZoomLevelContext* context) { |
| 55 context->DeleteOnCorrectThread(); | 56 context->DeleteOnCorrectThread(); |
| 56 } | 57 } |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 } // namespace content | 60 } // namespace content |
| 60 | 61 |
| 61 #endif // CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ | 62 #endif // CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ |
| OLD | NEW |