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"
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
26 class nsScreenManagerProxy MOZ_FINAL
: public nsIScreenManager
,
27 public mozilla::dom::PScreenManagerChild
30 nsScreenManagerProxy();
33 NS_DECL_NSISCREENMANAGER
36 ~nsScreenManagerProxy() {};
38 bool EnsureCacheIsValid();
39 void InvalidateCacheOnNextTick();
40 void InvalidateCache();
42 uint32_t mNumberOfScreens
;
43 float mSystemDefaultScale
;
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
58 struct ScreenCacheEntry
60 nsRefPtr
<mozilla::widget::ScreenProxy
> mScreenProxy
;
61 nsRefPtr
<mozilla::dom::TabChild
> mTabChild
;
64 nsTArray
<ScreenCacheEntry
> mScreenCache
;
67 #endif // nsScreenManagerProxy_h