Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: content/browser/host_zoom_map_impl.h

Issue 9416070: Move creation and ownership of HostZoomMap to content instead of having every embedder do this. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac/cros browsertests Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | content/browser/host_zoom_map_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_MAP_IMPL_H_ 5 #ifndef CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/message_loop_helpers.h" 14 #include "base/message_loop_helpers.h"
15 #include "base/supports_user_data.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "content/public/browser/host_zoom_map.h" 17 #include "content/public/browser/host_zoom_map.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 20
20 // HostZoomMap needs to be deleted on the UI thread because it listens 21 // HostZoomMap needs to be deleted on the UI thread because it listens
21 // to notifications on there (and holds a NotificationRegistrar). 22 // to notifications on there (and holds a NotificationRegistrar).
22 class CONTENT_EXPORT HostZoomMapImpl 23 class CONTENT_EXPORT HostZoomMapImpl
23 : public NON_EXPORTED_BASE(content::HostZoomMap), 24 : public NON_EXPORTED_BASE(content::HostZoomMap),
24 public content::NotificationObserver { 25 public content::NotificationObserver,
26 public base::SupportsUserData::Data {
25 public: 27 public:
26 HostZoomMapImpl(); 28 HostZoomMapImpl();
29 virtual ~HostZoomMapImpl();
27 30
28 // HostZoomMap implementation: 31 // HostZoomMap implementation:
29 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; 32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE;
30 virtual double GetZoomLevel(const std::string& host) const OVERRIDE; 33 virtual double GetZoomLevel(const std::string& host) const OVERRIDE;
31 virtual void SetZoomLevel(std::string host, double level) OVERRIDE; 34 virtual void SetZoomLevel(std::string host, double level) OVERRIDE;
32 virtual double GetDefaultZoomLevel() const OVERRIDE; 35 virtual double GetDefaultZoomLevel() const OVERRIDE;
33 virtual void SetDefaultZoomLevel(double level) OVERRIDE; 36 virtual void SetDefaultZoomLevel(double level) OVERRIDE;
34 37
35 // Returns the temporary zoom level that's only valid for the lifetime of 38 // Returns the temporary zoom level that's only valid for the lifetime of
36 // the given tab (i.e. isn't saved and doesn't affect other tabs) if it 39 // the given tab (i.e. isn't saved and doesn't affect other tabs) if it
(...skipping 12 matching lines...) Expand all
49 double level); 52 double level);
50 53
51 // content::NotificationObserver implementation. 54 // content::NotificationObserver implementation.
52 virtual void Observe(int type, 55 virtual void Observe(int type,
53 const content::NotificationSource& source, 56 const content::NotificationSource& source,
54 const content::NotificationDetails& details) OVERRIDE; 57 const content::NotificationDetails& details) OVERRIDE;
55 58
56 private: 59 private:
57 typedef std::map<std::string, double> HostZoomLevels; 60 typedef std::map<std::string, double> HostZoomLevels;
58 61
59 virtual ~HostZoomMapImpl();
60
61 // Copy of the pref data, so that we can read it on the IO thread. 62 // Copy of the pref data, so that we can read it on the IO thread.
62 HostZoomLevels host_zoom_levels_; 63 HostZoomLevels host_zoom_levels_;
63 double default_zoom_level_; 64 double default_zoom_level_;
64 65
65 struct TemporaryZoomLevel { 66 struct TemporaryZoomLevel {
66 int render_process_id; 67 int render_process_id;
67 int render_view_id; 68 int render_view_id;
68 double zoom_level; 69 double zoom_level;
69 }; 70 };
70 71
71 // Don't expect more than a couple of tabs that are using a temporary zoom 72 // Don't expect more than a couple of tabs that are using a temporary zoom
72 // level, so vector is fine for now. 73 // level, so vector is fine for now.
73 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; 74 std::vector<TemporaryZoomLevel> temporary_zoom_levels_;
74 75
75 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 76 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and
76 // |temporary_zoom_levels_| to guarantee thread safety. 77 // |temporary_zoom_levels_| to guarantee thread safety.
77 mutable base::Lock lock_; 78 mutable base::Lock lock_;
78 79
79 content::NotificationRegistrar registrar_; 80 content::NotificationRegistrar registrar_;
80 81
81 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 82 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
82 }; 83 };
83 84
84 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 85 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | content/browser/host_zoom_map_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698