Bumping manifests a=b2g-bump
[gecko.git] / widget / nsScreenManagerProxy.h
blob83f1d7c0fb2e62547a64fd015b95bd8189e3c7e1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsScreenManagerProxy_h
7 #define nsScreenManagerProxy_h
9 #include "nsIScreenManager.h"
10 #include "mozilla/dom/PScreenManagerChild.h"
11 #include "mozilla/dom/TabChild.h"
12 #include "ScreenProxy.h"
14 /**
15 * The nsScreenManagerProxy is used by the content process to get
16 * information about system screens. It uses the PScreenManager protocol
17 * to communicate with a PScreenManagerParent to get this information,
18 * and also caches the information it gets back.
20 * We cache both the system screen information that nsIScreenManagers
21 * provide, as well as the nsIScreens that callers can query for.
23 * Both of these caches are invalidated on the next tick of the event
24 * loop.
26 class nsScreenManagerProxy MOZ_FINAL : public nsIScreenManager,
27 public mozilla::dom::PScreenManagerChild
29 public:
30 nsScreenManagerProxy();
32 NS_DECL_ISUPPORTS
33 NS_DECL_NSISCREENMANAGER
35 private:
36 ~nsScreenManagerProxy() {};
38 bool EnsureCacheIsValid();
39 void InvalidateCacheOnNextTick();
40 void InvalidateCache();
42 uint32_t mNumberOfScreens;
43 float mSystemDefaultScale;
44 bool mCacheValid;
45 bool mCacheWillInvalidate;
47 nsRefPtr<mozilla::widget::ScreenProxy> mPrimaryScreen;
49 // nsScreenManagerProxy caches the results to repeated calls to
50 // ScreenForNativeWidget, which can be triggered indirectly by
51 // web content using the DOM Screen API. This allows us to bypass
52 // a lot of IPC traffic.
54 // The cache stores ScreenProxy's mapped to the TabChild that
55 // asked for the ScreenForNativeWidget was called with via
56 // ScreenCacheEntry's. The cache is cleared on the next tick of
57 // the event loop.
58 struct ScreenCacheEntry
60 nsRefPtr<mozilla::widget::ScreenProxy> mScreenProxy;
61 nsRefPtr<mozilla::dom::TabChild> mTabChild;
64 nsTArray<ScreenCacheEntry> mScreenCache;
67 #endif // nsScreenManagerProxy_h