Add remoting and PPAPI tests to GN build
[chromium-blink-merge.git] / content / browser / host_zoom_level_context.h
blobe45222f7f826ca0a3cb14e85599347a23221a217
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_
6 #define CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_
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"
14 class PrefService;
16 namespace content {
17 struct HostZoomLevelContextDeleter;
19 // 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 // separate from the owning StoragePartitionImpl.
22 class HostZoomLevelContext
23 : public base::RefCountedThreadSafe<HostZoomLevelContext,
24 HostZoomLevelContextDeleter> {
25 public:
26 explicit HostZoomLevelContext(
27 scoped_ptr<ZoomLevelDelegate> zoom_level_delegate);
29 HostZoomMap* GetHostZoomMap() const { return host_zoom_map_impl_.get(); }
30 ZoomLevelDelegate* GetZoomLevelDelegate() const {
31 return zoom_level_delegate_.get();
34 protected:
35 virtual ~HostZoomLevelContext();
37 private:
38 friend class base::DeleteHelper<HostZoomLevelContext>;
39 friend class base::RefCountedThreadSafe<HostZoomLevelContext,
40 HostZoomLevelContextDeleter>;
41 friend struct HostZoomLevelContextDeleter;
43 void DeleteOnCorrectThread() const;
45 scoped_ptr<HostZoomMapImpl> host_zoom_map_impl_;
46 // Release the delegate before the HostZoomMap, in case it is carrying
47 // any HostZoomMap::Subscription pointers.
48 scoped_ptr<ZoomLevelDelegate> zoom_level_delegate_;
50 DISALLOW_COPY_AND_ASSIGN(HostZoomLevelContext);
53 struct HostZoomLevelContextDeleter {
54 static void Destruct(const HostZoomLevelContext* context) {
55 context->DeleteOnCorrectThread();
59 } // namespace content
61 #endif // CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_