gecko-dev/widget/xpwidgets/nsScreenManagerProxy.h
Mike Conley 5f892c8286 Bug 1002354 - Proxy nsIScreenManager and nsIScreen's from the child process to the parent process, with caching. r=roc,jimm,smichaud,snorp.
Changes to nsIScreen and nsIScreenManager were reviewed by roc.
Changes to dom/ipc were reviewed by jimm.
Changes to gfx/src/nsDeviceContext.cpp were reviewed by roc.
Changes to widget/android were reviewed by snorp.
Changes to widget/cocoa were reviewed by smichaud.
Changes to widget/gtk were reviewed by roc.
Changes to widget/windows were reviewed by jimm.
Changes to widget/xpwidgets were reviewed by roc.

--HG--
extra : rebase_source : 3ebb5763d75d16f73b3cb5e4fc5621188b6c9622
2014-07-14 13:22:26 -04:00

68 lines
2.1 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsScreenManagerProxy_h
#define nsScreenManagerProxy_h
#include "nsIScreenManager.h"
#include "mozilla/dom/PScreenManagerChild.h"
#include "mozilla/dom/TabChild.h"
#include "ScreenProxy.h"
/**
* The nsScreenManagerProxy is used by the content process to get
* information about system screens. It uses the PScreenManager protocol
* to communicate with a PScreenManagerParent to get this information,
* and also caches the information it gets back.
*
* We cache both the system screen information that nsIScreenManagers
* provide, as well as the nsIScreens that callers can query for.
*
* Both of these caches are invalidated on the next tick of the event
* loop.
*/
class nsScreenManagerProxy MOZ_FINAL : public nsIScreenManager,
public mozilla::dom::PScreenManagerChild
{
public:
nsScreenManagerProxy();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
~nsScreenManagerProxy() {};
bool EnsureCacheIsValid();
void InvalidateCacheOnNextTick();
void InvalidateCache();
uint32_t mNumberOfScreens;
float mSystemDefaultScale;
bool mCacheValid;
bool mCacheWillInvalidate;
nsRefPtr<mozilla::widget::ScreenProxy> mPrimaryScreen;
// nsScreenManagerProxy caches the results to repeated calls to
// ScreenForNativeWidget, which can be triggered indirectly by
// web content using the DOM Screen API. This allows us to bypass
// a lot of IPC traffic.
//
// The cache stores ScreenProxy's mapped to the TabChild that
// asked for the ScreenForNativeWidget was called with via
// ScreenCacheEntry's. The cache is cleared on the next tick of
// the event loop.
struct ScreenCacheEntry
{
nsRefPtr<mozilla::widget::ScreenProxy> mScreenProxy;
nsRefPtr<mozilla::dom::TabChild> mTabChild;
};
nsTArray<ScreenCacheEntry> mScreenCache;
};
#endif // nsScreenManagerProxy_h