Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataObject.cpp

Issue 2657443005: Migrate WTF::HashSet::add() to ::insert() [part 1 of N] (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 uint64_t sequenceNumber = 50 uint64_t sequenceNumber =
51 Platform::current()->clipboard()->sequenceNumber(buffer); 51 Platform::current()->clipboard()->sequenceNumber(buffer);
52 bool ignored; 52 bool ignored;
53 WebVector<WebString> webTypes = 53 WebVector<WebString> webTypes =
54 Platform::current()->clipboard()->readAvailableTypes(buffer, &ignored); 54 Platform::current()->clipboard()->readAvailableTypes(buffer, &ignored);
55 for (const WebString& type : webTypes) { 55 for (const WebString& type : webTypes) {
56 if (pasteMode == PlainTextOnly && type != mimeTypeTextPlain) 56 if (pasteMode == PlainTextOnly && type != mimeTypeTextPlain)
57 continue; 57 continue;
58 dataObject->m_itemList.push_back( 58 dataObject->m_itemList.push_back(
59 DataObjectItem::createFromPasteboard(type, sequenceNumber)); 59 DataObjectItem::createFromPasteboard(type, sequenceNumber));
60 ASSERT(typesSeen.add(type).isNewEntry); 60 ASSERT(typesSeen.insert(type).isNewEntry);
61 } 61 }
62 return dataObject; 62 return dataObject;
63 } 63 }
64 64
65 DataObject* DataObject::createFromString(const String& data) { 65 DataObject* DataObject::createFromString(const String& data) {
66 DataObject* dataObject = create(); 66 DataObject* dataObject = create();
67 dataObject->add(data, mimeTypeTextPlain); 67 dataObject->add(data, mimeTypeTextPlain);
68 return dataObject; 68 return dataObject;
69 } 69 }
70 70
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 Vector<String> results; 135 Vector<String> results;
136 #if DCHECK_IS_ON() 136 #if DCHECK_IS_ON()
137 HashSet<String> typesSeen; 137 HashSet<String> typesSeen;
138 #endif 138 #endif
139 bool containsFiles = false; 139 bool containsFiles = false;
140 for (const auto& item : m_itemList) { 140 for (const auto& item : m_itemList) {
141 switch (item->kind()) { 141 switch (item->kind()) {
142 case DataObjectItem::StringKind: 142 case DataObjectItem::StringKind:
143 // Per the spec, type must be unique among all items of kind 'string'. 143 // Per the spec, type must be unique among all items of kind 'string'.
144 results.push_back(item->type()); 144 results.push_back(item->type());
145 ASSERT(typesSeen.add(item->type()).isNewEntry); 145 ASSERT(typesSeen.insert(item->type()).isNewEntry);
146 break; 146 break;
147 case DataObjectItem::FileKind: 147 case DataObjectItem::FileKind:
148 containsFiles = true; 148 containsFiles = true;
149 break; 149 break;
150 } 150 }
151 } 151 }
152 if (containsFiles) { 152 if (containsFiles) {
153 results.push_back(mimeTypeFiles); 153 results.push_back(mimeTypeFiles);
154 ASSERT(typesSeen.add(mimeTypeFiles).isNewEntry); 154 ASSERT(typesSeen.insert(mimeTypeFiles).isNewEntry);
155 } 155 }
156 return results; 156 return results;
157 } 157 }
158 158
159 String DataObject::getData(const String& type) const { 159 String DataObject::getData(const String& type) const {
160 for (size_t i = 0; i < m_itemList.size(); ++i) { 160 for (size_t i = 0; i < m_itemList.size(); ++i) {
161 if (m_itemList[i]->kind() == DataObjectItem::StringKind && 161 if (m_itemList[i]->kind() == DataObjectItem::StringKind &&
162 m_itemList[i]->type() == type) 162 m_itemList[i]->type() == type)
163 return m_itemList[i]->getAsString(); 163 return m_itemList[i]->getAsString();
164 } 164 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 357 }
358 item.title = originalItem->title(); 358 item.title = originalItem->title();
359 item.baseURL = originalItem->baseURL(); 359 item.baseURL = originalItem->baseURL();
360 itemList[i] = item; 360 itemList[i] = item;
361 } 361 }
362 data.swapItems(itemList); 362 data.swapItems(itemList);
363 return data; 363 return data;
364 } 364 }
365 365
366 } // namespace blink 366 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698