Don't preload rarely seen large images
[chromium-blink-merge.git] / components / clipboard / clipboard_standalone_impl.h
blob218c96cb899b1a596eb646ba70a9065edf614f36
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_
6 #define COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_
8 #include <base/memory/scoped_ptr.h>
9 #include <string>
11 #include "components/clipboard/public/interfaces/clipboard.mojom.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
14 namespace clipboard {
16 // Stub clipboard implementation.
18 // Eventually, we'll actually want to interact with the system clipboard, but
19 // that's hard today because the system clipboard is asynchronous (on X11), the
20 // ui::Clipboard interface is synchronous (which is what we'd use), mojo is
21 // asynchronous across processes, and the WebClipboard interface is synchronous
22 // (which is at least tractable).
23 class ClipboardStandaloneImpl : public mojo::Clipboard {
24 public:
25 // mojo::Clipboard exposes three possible clipboards.
26 static const int kNumClipboards = 3;
28 explicit ClipboardStandaloneImpl(
29 mojo::InterfaceRequest<mojo::Clipboard> request);
30 ~ClipboardStandaloneImpl() override;
32 // mojo::Clipboard implementation.
33 void GetSequenceNumber(
34 mojo::Clipboard::Type clipboard_type,
35 const mojo::Callback<void(uint64_t)>& callback) override;
36 void GetAvailableMimeTypes(
37 mojo::Clipboard::Type clipboard_types,
38 const mojo::Callback<void(mojo::Array<mojo::String>)>& callback) override;
39 void ReadMimeType(
40 mojo::Clipboard::Type clipboard_type,
41 const mojo::String& mime_type,
42 const mojo::Callback<void(mojo::Array<uint8_t>)>& callback) override;
43 void WriteClipboardData(
44 mojo::Clipboard::Type clipboard_type,
45 mojo::Map<mojo::String, mojo::Array<uint8_t>> data) override;
47 private:
48 uint64_t sequence_number_[kNumClipboards];
50 // Internal struct which stores the current state of the clipboard.
51 class ClipboardData;
53 // The current clipboard state. This is what is read from.
54 scoped_ptr<ClipboardData> clipboard_state_[kNumClipboards];
55 mojo::StrongBinding<mojo::Clipboard> binding_;
57 DISALLOW_COPY_AND_ASSIGN(ClipboardStandaloneImpl);
60 } // namespace clipboard
62 #endif // COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_