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

Side by Side Diff: content/browser/indexed_db/indexed_db_leveldb_coding.cc

Issue 202863004: Fix "unreachable code" warnings (MSVC warning 4702) in content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/indexed_db/indexed_db_leveldb_coding.h" 5 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 void EncodeDouble(double value, std::string* into) { 303 void EncodeDouble(double value, std::string* into) {
304 // This always has host endianness. 304 // This always has host endianness.
305 const char* p = reinterpret_cast<char*>(&value); 305 const char* p = reinterpret_cast<char*>(&value);
306 into->insert(into->end(), p, p + sizeof(value)); 306 into->insert(into->end(), p, p + sizeof(value));
307 } 307 }
308 308
309 void EncodeIDBKey(const IndexedDBKey& value, std::string* into) { 309 void EncodeIDBKey(const IndexedDBKey& value, std::string* into) {
310 size_t previous_size = into->size(); 310 size_t previous_size = into->size();
311 DCHECK(value.IsValid()); 311 DCHECK(value.IsValid());
312 switch (value.type()) { 312 switch (value.type()) {
313 case WebIDBKeyTypeNull:
314 case WebIDBKeyTypeInvalid:
315 case WebIDBKeyTypeMin:
316 default: {
317 NOTREACHED();
318 EncodeByte(kIndexedDBKeyNullTypeByte, into);
319 return;
320 }
321 case WebIDBKeyTypeArray: { 313 case WebIDBKeyTypeArray: {
322 EncodeByte(kIndexedDBKeyArrayTypeByte, into); 314 EncodeByte(kIndexedDBKeyArrayTypeByte, into);
323 size_t length = value.array().size(); 315 size_t length = value.array().size();
324 EncodeVarInt(length, into); 316 EncodeVarInt(length, into);
325 for (size_t i = 0; i < length; ++i) 317 for (size_t i = 0; i < length; ++i)
326 EncodeIDBKey(value.array()[i], into); 318 EncodeIDBKey(value.array()[i], into);
327 DCHECK_GT(into->size(), previous_size); 319 DCHECK_GT(into->size(), previous_size);
328 return; 320 return;
329 } 321 }
330 case WebIDBKeyTypeBinary: { 322 case WebIDBKeyTypeBinary:
331 EncodeByte(kIndexedDBKeyBinaryTypeByte, into); 323 EncodeByte(kIndexedDBKeyBinaryTypeByte, into);
332 EncodeBinary(value.binary(), into); 324 EncodeBinary(value.binary(), into);
333 DCHECK_GT(into->size(), previous_size); 325 DCHECK_GT(into->size(), previous_size);
334 return; 326 return;
335 } 327 case WebIDBKeyTypeString:
336 case WebIDBKeyTypeString: {
337 EncodeByte(kIndexedDBKeyStringTypeByte, into); 328 EncodeByte(kIndexedDBKeyStringTypeByte, into);
338 EncodeStringWithLength(value.string(), into); 329 EncodeStringWithLength(value.string(), into);
339 DCHECK_GT(into->size(), previous_size); 330 DCHECK_GT(into->size(), previous_size);
340 return; 331 return;
341 } 332 case WebIDBKeyTypeDate:
342 case WebIDBKeyTypeDate: {
343 EncodeByte(kIndexedDBKeyDateTypeByte, into); 333 EncodeByte(kIndexedDBKeyDateTypeByte, into);
344 EncodeDouble(value.date(), into); 334 EncodeDouble(value.date(), into);
345 DCHECK_EQ(9u, static_cast<size_t>(into->size() - previous_size)); 335 DCHECK_EQ(9u, static_cast<size_t>(into->size() - previous_size));
346 return; 336 return;
347 } 337 case WebIDBKeyTypeNumber:
348 case WebIDBKeyTypeNumber: {
349 EncodeByte(kIndexedDBKeyNumberTypeByte, into); 338 EncodeByte(kIndexedDBKeyNumberTypeByte, into);
350 EncodeDouble(value.number(), into); 339 EncodeDouble(value.number(), into);
351 DCHECK_EQ(9u, static_cast<size_t>(into->size() - previous_size)); 340 DCHECK_EQ(9u, static_cast<size_t>(into->size() - previous_size));
352 return; 341 return;
353 } 342 case WebIDBKeyTypeNull:
343 case WebIDBKeyTypeInvalid:
344 case WebIDBKeyTypeMin:
345 default:
346 NOTREACHED();
347 EncodeByte(kIndexedDBKeyNullTypeByte, into);
348 return;
354 } 349 }
355
356 NOTREACHED();
357 } 350 }
358 351
359 void EncodeIDBKeyPath(const IndexedDBKeyPath& value, std::string* into) { 352 void EncodeIDBKeyPath(const IndexedDBKeyPath& value, std::string* into) {
360 // May be typed, or may be a raw string. An invalid leading 353 // May be typed, or may be a raw string. An invalid leading
361 // byte is used to identify typed coding. New records are 354 // byte is used to identify typed coding. New records are
362 // always written as typed. 355 // always written as typed.
363 EncodeByte(kIndexedDBKeyPathTypeCodedByte1, into); 356 EncodeByte(kIndexedDBKeyPathTypeCodedByte1, into);
364 EncodeByte(kIndexedDBKeyPathTypeCodedByte2, into); 357 EncodeByte(kIndexedDBKeyPathTypeCodedByte2, into);
365 EncodeByte(static_cast<char>(value.type()), into); 358 EncodeByte(static_cast<char>(value.type()), into);
366 switch (value.type()) { 359 switch (value.type()) {
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 scoped_ptr<IndexedDBKey> IndexDataKey::primary_key() const { 2000 scoped_ptr<IndexedDBKey> IndexDataKey::primary_key() const {
2008 scoped_ptr<IndexedDBKey> key; 2001 scoped_ptr<IndexedDBKey> key;
2009 StringPiece slice(encoded_primary_key_); 2002 StringPiece slice(encoded_primary_key_);
2010 if (!DecodeIDBKey(&slice, &key)) { 2003 if (!DecodeIDBKey(&slice, &key)) {
2011 // TODO(jsbell): Return error. 2004 // TODO(jsbell): Return error.
2012 } 2005 }
2013 return key.Pass(); 2006 return key.Pass();
2014 } 2007 }
2015 2008
2016 } // namespace content 2009 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/compositor_util.cc ('k') | content/browser/renderer_host/input/gesture_event_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698