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

Side by Side Diff: content/common/indexed_db/indexed_db_struct_traits.cc

Issue 2642973006: Include AIDL files in the presubmit check for IPC security. (Closed)
Patch Set: Move `using` statements. Created 3 years, 11 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
« no previous file with comments | « content/common/indexed_db/indexed_db_struct_traits.h ('k') | ui/base/mojo/OWNERS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/indexed_db/indexed_db_struct_traits.h" 5 #include "content/common/indexed_db/indexed_db_struct_traits.h"
6 #include "mojo/common/common_custom_types_struct_traits.h" 6 #include "mojo/common/common_custom_types_struct_traits.h"
7 7
8 using content::IndexedDBKey; 8 using content::IndexedDBKey;
9 using content::IndexedDBKeyPath; 9 using content::IndexedDBKeyPath;
10 using content::IndexedDBKeyRange; 10 using content::IndexedDBKeyRange;
11 using indexed_db::mojom::CursorDirection;
12 using indexed_db::mojom::DataLoss;
13 using indexed_db::mojom::OperationType;
14 using indexed_db::mojom::PutMode;
15 using indexed_db::mojom::TaskType;
16 using indexed_db::mojom::TransactionMode;
11 17
12 namespace mojo { 18 namespace mojo {
13 19
14 // static 20 // static
15 indexed_db::mojom::KeyDataPtr 21 indexed_db::mojom::KeyDataPtr
16 StructTraits<indexed_db::mojom::KeyDataView, IndexedDBKey>::data( 22 StructTraits<indexed_db::mojom::KeyDataView, IndexedDBKey>::data(
17 const IndexedDBKey& key) { 23 const IndexedDBKey& key) {
18 auto data = indexed_db::mojom::KeyData::New(); 24 auto data = indexed_db::mojom::KeyData::New();
19 switch (key.type()) { 25 switch (key.type()) {
20 case blink::WebIDBKeyTypeInvalid: 26 case blink::WebIDBKeyTypeInvalid:
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 object_stores.GetDataView(i, &object_store); 236 object_stores.GetDataView(i, &object_store);
231 DCHECK(!base::ContainsKey(out->object_stores, object_store.id())); 237 DCHECK(!base::ContainsKey(out->object_stores, object_store.id()));
232 if (!StructTraits<indexed_db::mojom::ObjectStoreMetadataDataView, 238 if (!StructTraits<indexed_db::mojom::ObjectStoreMetadataDataView,
233 content::IndexedDBObjectStoreMetadata>:: 239 content::IndexedDBObjectStoreMetadata>::
234 Read(object_store, &out->object_stores[object_store.id()])) 240 Read(object_store, &out->object_stores[object_store.id()]))
235 return false; 241 return false;
236 } 242 }
237 return true; 243 return true;
238 } 244 }
239 245
246 // static
247 CursorDirection
248 EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::ToMojom(
249 blink::WebIDBCursorDirection input) {
250 switch (input) {
251 case blink::WebIDBCursorDirectionNext:
252 return CursorDirection::Next;
253 case blink::WebIDBCursorDirectionNextNoDuplicate:
254 return CursorDirection::NextNoDuplicate;
255 case blink::WebIDBCursorDirectionPrev:
256 return CursorDirection::Prev;
257 case blink::WebIDBCursorDirectionPrevNoDuplicate:
258 return CursorDirection::PrevNoDuplicate;
259 }
260 NOTREACHED();
261 return CursorDirection::Next;
262 }
263
264 // static
265 bool EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::FromMojom(
266 CursorDirection input,
267 blink::WebIDBCursorDirection* output) {
268 switch (input) {
269 case CursorDirection::Next:
270 *output = blink::WebIDBCursorDirectionNext;
271 return true;
272 case CursorDirection::NextNoDuplicate:
273 *output = blink::WebIDBCursorDirectionNextNoDuplicate;
274 return true;
275 case CursorDirection::Prev:
276 *output = blink::WebIDBCursorDirectionPrev;
277 return true;
278 case CursorDirection::PrevNoDuplicate:
279 *output = blink::WebIDBCursorDirectionPrevNoDuplicate;
280 return true;
281 }
282 return false;
283 }
284
285 // static
286 DataLoss EnumTraits<DataLoss, blink::WebIDBDataLoss>::ToMojom(
287 blink::WebIDBDataLoss input) {
288 switch (input) {
289 case blink::WebIDBDataLossNone:
290 return DataLoss::None;
291 case blink::WebIDBDataLossTotal:
292 return DataLoss::Total;
293 }
294 NOTREACHED();
295 return DataLoss::None;
296 }
297
298 // static
299 bool EnumTraits<DataLoss, blink::WebIDBDataLoss>::FromMojom(
300 DataLoss input,
301 blink::WebIDBDataLoss* output) {
302 switch (input) {
303 case DataLoss::None:
304 *output = blink::WebIDBDataLossNone;
305 return true;
306 case DataLoss::Total:
307 *output = blink::WebIDBDataLossTotal;
308 return true;
309 }
310 return false;
311 }
312
313 // static
314 OperationType EnumTraits<OperationType, blink::WebIDBOperationType>::ToMojom(
315 blink::WebIDBOperationType input) {
316 switch (input) {
317 case blink::WebIDBAdd:
318 return OperationType::Add;
319 case blink::WebIDBPut:
320 return OperationType::Put;
321 case blink::WebIDBDelete:
322 return OperationType::Delete;
323 case blink::WebIDBClear:
324 return OperationType::Clear;
325 case blink::WebIDBOperationTypeCount:
326 // WebIDBOperationTypeCount is not a valid option.
327 break;
328 }
329 NOTREACHED();
330 return OperationType::Add;
331 }
332
333 // static
334 bool EnumTraits<OperationType, blink::WebIDBOperationType>::FromMojom(
335 OperationType input,
336 blink::WebIDBOperationType* output) {
337 switch (input) {
338 case OperationType::Add:
339 *output = blink::WebIDBAdd;
340 return true;
341 case OperationType::Put:
342 *output = blink::WebIDBPut;
343 return true;
344 case OperationType::Delete:
345 *output = blink::WebIDBDelete;
346 return true;
347 case OperationType::Clear:
348 *output = blink::WebIDBClear;
349 return true;
350 }
351 return false;
352 }
353
354 // static
355 PutMode EnumTraits<PutMode, blink::WebIDBPutMode>::ToMojom(
356 blink::WebIDBPutMode input) {
357 switch (input) {
358 case blink::WebIDBPutModeAddOrUpdate:
359 return PutMode::AddOrUpdate;
360 case blink::WebIDBPutModeAddOnly:
361 return PutMode::AddOnly;
362 case blink::WebIDBPutModeCursorUpdate:
363 return PutMode::CursorUpdate;
364 }
365 NOTREACHED();
366 return PutMode::AddOrUpdate;
367 }
368
369 // static
370 bool EnumTraits<PutMode, blink::WebIDBPutMode>::FromMojom(
371 PutMode input,
372 blink::WebIDBPutMode* output) {
373 switch (input) {
374 case PutMode::AddOrUpdate:
375 *output = blink::WebIDBPutModeAddOrUpdate;
376 return true;
377 case PutMode::AddOnly:
378 *output = blink::WebIDBPutModeAddOnly;
379 return true;
380 case PutMode::CursorUpdate:
381 *output = blink::WebIDBPutModeCursorUpdate;
382 return true;
383 }
384 return false;
385 }
386
387 // static
388 TaskType EnumTraits<TaskType, blink::WebIDBTaskType>::ToMojom(
389 blink::WebIDBTaskType input) {
390 switch (input) {
391 case blink::WebIDBTaskTypeNormal:
392 return TaskType::Normal;
393 case blink::WebIDBTaskTypePreemptive:
394 return TaskType::Preemptive;
395 }
396 NOTREACHED();
397 return TaskType::Normal;
398 }
399
400 // static
401 bool EnumTraits<TaskType, blink::WebIDBTaskType>::FromMojom(
402 TaskType input,
403 blink::WebIDBTaskType* output) {
404 switch (input) {
405 case TaskType::Normal:
406 *output = blink::WebIDBTaskTypeNormal;
407 return true;
408 case TaskType::Preemptive:
409 *output = blink::WebIDBTaskTypePreemptive;
410 return true;
411 }
412 return false;
413 }
414
415 // static
416 TransactionMode
417 EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::ToMojom(
418 blink::WebIDBTransactionMode input) {
419 switch (input) {
420 case blink::WebIDBTransactionModeReadOnly:
421 return TransactionMode::ReadOnly;
422 case blink::WebIDBTransactionModeReadWrite:
423 return TransactionMode::ReadWrite;
424 case blink::WebIDBTransactionModeVersionChange:
425 return TransactionMode::VersionChange;
426 }
427 NOTREACHED();
428 return TransactionMode::ReadOnly;
429 }
430
431 // static
432 bool EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::FromMojom(
433 TransactionMode input,
434 blink::WebIDBTransactionMode* output) {
435 switch (input) {
436 case TransactionMode::ReadOnly:
437 *output = blink::WebIDBTransactionModeReadOnly;
438 return true;
439 case TransactionMode::ReadWrite:
440 *output = blink::WebIDBTransactionModeReadWrite;
441 return true;
442 case TransactionMode::VersionChange:
443 *output = blink::WebIDBTransactionModeVersionChange;
444 return true;
445 }
446 return false;
447 }
240 } // namespace mojo 448 } // namespace mojo
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_struct_traits.h ('k') | ui/base/mojo/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698