mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
14d41cb7f9
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async clipboard API reads the clipboard data asynchronously. When reading, async clipboard API first check the available types, and then retrieve the actual data for that type. This process has a potential race condition: the clipboard content might change between the time between the time we check the types and when we retrieve the data. Although we currently fetch the actual data immediately after checking available types (in line with the spec), this minimizes the chance of encountering this race condition. However, if we would like to support retrieving the data only when `getType()` is invoked (bug 1691825), this potential race condition could become a significant issue. Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress the paste context menu when the clipboard data originates from a same-origin page. This also requires a better way to track read requests, clipboard content and invalidate the request when the system's clipboard content is changed. After some refacting around nsBaseClipboard, all platform now use sequence number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated with a sequence number and deemed invalid if the associated sequence number isn't matched the latest system value. With these new API, it also becomes possible to write some tests. Depends on D191409 Differential Revision: https://phabricator.services.mozilla.com/D182108
35 lines
997 B
C++
35 lines
997 B
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 mozilla_ClipboardReadRequestChild_h
|
|
#define mozilla_ClipboardReadRequestChild_h
|
|
|
|
#include "mozilla/PClipboardReadRequestChild.h"
|
|
|
|
class nsITransferable;
|
|
|
|
namespace mozilla {
|
|
|
|
class ClipboardReadRequestChild final : public PClipboardReadRequestChild {
|
|
public:
|
|
explicit ClipboardReadRequestChild(const nsTArray<nsCString>& aFlavorList) {
|
|
mFlavorList.AppendElements(aFlavorList);
|
|
}
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(ClipboardReadRequestChild)
|
|
|
|
const nsTArray<nsCString>& FlavorList() const { return mFlavorList; }
|
|
|
|
protected:
|
|
virtual ~ClipboardReadRequestChild() = default;
|
|
|
|
private:
|
|
nsTArray<nsCString> mFlavorList;
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_ClipboardReadRequestChild_h
|