Chromium Code Reviews| Index: ui/base/clipboard/clipboard_aurax11.cc |
| diff --git a/ui/base/clipboard/clipboard_aurax11.cc b/ui/base/clipboard/clipboard_aurax11.cc |
| index 39e864738f682bd38aa41e3fe66bb17392796d10..8458550ff14cdebc9d370d0b21589413af2f4858 100644 |
| --- a/ui/base/clipboard/clipboard_aurax11.cc |
| +++ b/ui/base/clipboard/clipboard_aurax11.cc |
| @@ -34,7 +34,6 @@ |
| #include "ui/events/platform/platform_event_source.h" |
| #include "ui/gfx/codec/png_codec.h" |
| #include "ui/gfx/geometry/size.h" |
| -#include "ui/gfx/x/x11_atom_cache.h" |
| namespace ui { |
| @@ -46,19 +45,6 @@ const char kMimeTypeFilename[] = "chromium/filename"; |
| const char kSaveTargets[] = "SAVE_TARGETS"; |
| const char kTargets[] = "TARGETS"; |
| -const char* kAtomsToCache[] = {kClipboard, |
| - kClipboardManager, |
| - Clipboard::kMimeTypePNG, |
| - kMimeTypeFilename, |
| - Clipboard::kMimeTypeMozillaURL, |
| - Clipboard::kMimeTypeWebkitSmartPaste, |
| - kSaveTargets, |
| - kString, |
| - kTargets, |
| - kText, |
| - kUtf8String, |
| - nullptr}; |
| - |
| /////////////////////////////////////////////////////////////////////////////// |
| // Uses the XFixes API to provide sequence numbers for GetSequenceNumber(). |
| @@ -96,7 +82,7 @@ SelectionChangeObserver::SelectionChangeObserver() |
| primary_sequence_number_(0) { |
| int ignored; |
| if (XFixesQueryExtension(gfx::GetXDisplay(), &event_base_, &ignored)) { |
| - clipboard_atom_ = XInternAtom(gfx::GetXDisplay(), kClipboard, false); |
| + clipboard_atom_ = GetAtom(kClipboard); |
| XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(), |
| clipboard_atom_, |
| XFixesSetSelectionOwnerNotifyMask | |
| @@ -145,7 +131,7 @@ class TargetList { |
| public: |
| typedef std::vector< ::Atom> AtomVector; |
| - TargetList(const AtomVector& target_list, X11AtomCache* atom_cache); |
| + TargetList(const AtomVector& target_list); |
|
sadrul
2017/06/01 20:45:30
explicit
Tom Anderson
2017/06/01 21:20:42
Done.
|
| const AtomVector& target_list() { return target_list_; } |
| @@ -155,17 +141,13 @@ class TargetList { |
| private: |
| AtomVector target_list_; |
| - X11AtomCache* atom_cache_; |
| }; |
| -TargetList::TargetList(const AtomVector& target_list, |
| - X11AtomCache* atom_cache) |
| - : target_list_(target_list), |
| - atom_cache_(atom_cache) { |
| -} |
| +TargetList::TargetList(const AtomVector& target_list) |
| + : target_list_(target_list) {} |
| bool TargetList::ContainsText() const { |
| - std::vector< ::Atom> atoms = GetTextAtomsFrom(atom_cache_); |
| + std::vector<::Atom> atoms = GetTextAtomsFrom(); |
| for (std::vector< ::Atom>::const_iterator it = atoms.begin(); |
| it != atoms.end(); ++it) { |
| if (ContainsAtom(*it)) |
| @@ -177,7 +159,7 @@ bool TargetList::ContainsText() const { |
| bool TargetList::ContainsFormat( |
| const Clipboard::FormatType& format_type) const { |
| - ::Atom atom = atom_cache_->GetAtom(format_type.ToString().c_str()); |
| + ::Atom atom = GetAtom(format_type.ToString().c_str()); |
| return ContainsAtom(atom); |
| } |
| @@ -233,8 +215,6 @@ class ClipboardAuraX11::AuraX11Details : public PlatformEventDispatcher { |
| AuraX11Details(); |
| ~AuraX11Details() override; |
| - X11AtomCache* atom_cache() { return &atom_cache_; } |
| - |
| // Returns the X11 type that we pass to various XSelection functions for the |
| // given type. |
| ::Atom LookupSelectionForClipboardType(ClipboardType type) const; |
| @@ -305,8 +285,6 @@ class ClipboardAuraX11::AuraX11Details : public PlatformEventDispatcher { |
| // Events selected on |x_window_|. |
| std::unique_ptr<XScopedEventSelector> x_window_events_; |
| - X11AtomCache atom_cache_; |
| - |
| // Object which requests and receives selection data. |
| SelectionRequestor selection_requestor_; |
| @@ -335,13 +313,9 @@ ClipboardAuraX11::AuraX11Details::AuraX11Details() |
| CopyFromParent, // visual |
| 0, |
| NULL)), |
| - atom_cache_(x_display_, kAtomsToCache), |
| selection_requestor_(x_display_, x_window_, this), |
| - clipboard_owner_(x_display_, x_window_, atom_cache_.GetAtom(kClipboard)), |
| + clipboard_owner_(x_display_, x_window_, GetAtom(kClipboard)), |
| primary_owner_(x_display_, x_window_, XA_PRIMARY) { |
| - // We don't know all possible MIME types at compile time. |
| - atom_cache_.allow_uncached_atoms(); |
| - |
| XStoreName(x_display_, x_window_, "Chromium clipboard"); |
| x_window_events_.reset( |
| new XScopedEventSelector(x_window_, PropertyChangeMask)); |
| @@ -366,7 +340,7 @@ ClipboardAuraX11::AuraX11Details::~AuraX11Details() { |
| } |
| ::Atom ClipboardAuraX11::AuraX11Details::GetCopyPasteSelection() const { |
| - return atom_cache_.GetAtom(kClipboard); |
| + return GetAtom(kClipboard); |
| } |
| const SelectionFormatMap& |
| @@ -385,7 +359,7 @@ void ClipboardAuraX11::AuraX11Details::CreateNewClipboardData() { |
| void ClipboardAuraX11::AuraX11Details::InsertMapping( |
| const std::string& key, |
| const scoped_refptr<base::RefCountedMemory>& memory) { |
| - ::Atom atom_key = atom_cache_.GetAtom(key.c_str()); |
| + ::Atom atom_key = GetAtom(key.c_str()); |
| clipboard_data_.Insert(atom_key, memory); |
| } |
| @@ -443,13 +417,10 @@ TargetList ClipboardAuraX11::AuraX11Details::WaitAndGetTargetsList( |
| ::Atom out_type = None; |
| if (selection_requestor_.PerformBlockingConvertSelection( |
| - selection_name, |
| - atom_cache_.GetAtom(kTargets), |
| - &data, |
| - &out_data_items, |
| + selection_name, GetAtom(kTargets), &data, &out_data_items, |
| &out_type)) { |
| // Some apps return an |out_type| of "TARGETS". (crbug.com/377893) |
| - if (out_type == XA_ATOM || out_type == atom_cache_.GetAtom(kTargets)) { |
| + if (out_type == XA_ATOM || out_type == GetAtom(kTargets)) { |
| const ::Atom* atom_array = |
| reinterpret_cast<const ::Atom*>(data->front()); |
| for (size_t i = 0; i < out_data_items; ++i) |
| @@ -478,17 +449,17 @@ TargetList ClipboardAuraX11::AuraX11Details::WaitAndGetTargetsList( |
| } |
| } |
| - return TargetList(out, &atom_cache_); |
| + return TargetList(out); |
| } |
| std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetTextAtoms() const { |
| - return GetTextAtomsFrom(&atom_cache_); |
| + return GetTextAtomsFrom(); |
| } |
| std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetAtomsForFormat( |
| const Clipboard::FormatType& format) { |
| std::vector< ::Atom> atoms; |
| - atoms.push_back(atom_cache_.GetAtom(format.ToString().c_str())); |
| + atoms.push_back(GetAtom(format.ToString().c_str())); |
| return atoms; |
| } |
| @@ -504,7 +475,7 @@ void ClipboardAuraX11::AuraX11Details::StoreCopyPasteDataAndWait() { |
| if (XGetSelectionOwner(x_display_, selection) != x_window_) |
| return; |
| - ::Atom clipboard_manager_atom = atom_cache_.GetAtom(kClipboardManager); |
| + ::Atom clipboard_manager_atom = GetAtom(kClipboardManager); |
| if (XGetSelectionOwner(x_display_, clipboard_manager_atom) == None) |
| return; |
| @@ -515,9 +486,7 @@ void ClipboardAuraX11::AuraX11Details::StoreCopyPasteDataAndWait() { |
| base::TimeTicks start = base::TimeTicks::Now(); |
| selection_requestor_.PerformBlockingConvertSelectionWithParameter( |
| - atom_cache_.GetAtom(kClipboardManager), |
| - atom_cache_.GetAtom(kSaveTargets), |
| - targets); |
| + GetAtom(kClipboardManager), GetAtom(kSaveTargets), targets); |
| UMA_HISTOGRAM_TIMES("Clipboard.X11StoreCopyPasteDuration", |
| base::TimeTicks::Now() - start); |
| } |