OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/drive/drive_file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/common/chrome_version_info.h" | 29 #include "chrome/common/chrome_version_info.h" |
30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
32 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
33 #include "net/base/network_change_notifier.h" | 33 #include "net/base/network_change_notifier.h" |
34 | 34 |
35 using content::BrowserThread; | 35 using content::BrowserThread; |
36 | 36 |
37 namespace gdata { | 37 namespace drive { |
38 namespace util { | 38 namespace util { |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 const char kDriveSpecialRootPath[] = "/special"; | 42 const char kDriveSpecialRootPath[] = "/special"; |
43 | 43 |
44 const char kDriveMountPointPath[] = "/special/drive"; | 44 const char kDriveMountPointPath[] = "/special/drive"; |
45 | 45 |
46 const FilePath::CharType* kDriveMountPointPathComponents[] = { | 46 const FilePath::CharType* kDriveMountPointPathComponents[] = { |
47 "/", "special", "drive" | 47 "/", "special", "drive" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 ExtractDrivePath(directory), | 411 ExtractDrivePath(directory), |
412 true /* is_exclusive */, | 412 true /* is_exclusive */, |
413 true /* is_recursive */, | 413 true /* is_recursive */, |
414 callback); | 414 callback); |
415 } else { | 415 } else { |
416 base::MessageLoopProxy::current()->PostTask( | 416 base::MessageLoopProxy::current()->PostTask( |
417 FROM_HERE, base::Bind(callback, DRIVE_FILE_OK)); | 417 FROM_HERE, base::Bind(callback, DRIVE_FILE_OK)); |
418 } | 418 } |
419 } | 419 } |
420 | 420 |
421 DriveFileError GDataToDriveFileError(GDataErrorCode status) { | 421 DriveFileError GDataToDriveFileError(gdata::GDataErrorCode status) { |
422 switch (status) { | 422 switch (status) { |
423 case HTTP_SUCCESS: | 423 case gdata::HTTP_SUCCESS: |
424 case HTTP_CREATED: | 424 case gdata::HTTP_CREATED: |
425 return DRIVE_FILE_OK; | 425 return DRIVE_FILE_OK; |
426 case HTTP_UNAUTHORIZED: | 426 case gdata::HTTP_UNAUTHORIZED: |
427 case HTTP_FORBIDDEN: | 427 case gdata::HTTP_FORBIDDEN: |
428 return DRIVE_FILE_ERROR_ACCESS_DENIED; | 428 return DRIVE_FILE_ERROR_ACCESS_DENIED; |
429 case HTTP_NOT_FOUND: | 429 case gdata::HTTP_NOT_FOUND: |
430 return DRIVE_FILE_ERROR_NOT_FOUND; | 430 return DRIVE_FILE_ERROR_NOT_FOUND; |
431 case GDATA_PARSE_ERROR: | 431 case gdata::GDATA_PARSE_ERROR: |
432 case GDATA_FILE_ERROR: | 432 case gdata::GDATA_FILE_ERROR: |
433 return DRIVE_FILE_ERROR_ABORT; | 433 return DRIVE_FILE_ERROR_ABORT; |
434 case GDATA_NO_CONNECTION: | 434 case gdata::GDATA_NO_CONNECTION: |
435 return DRIVE_FILE_ERROR_NO_CONNECTION; | 435 return DRIVE_FILE_ERROR_NO_CONNECTION; |
436 case HTTP_SERVICE_UNAVAILABLE: | 436 case gdata::HTTP_SERVICE_UNAVAILABLE: |
437 case HTTP_INTERNAL_SERVER_ERROR: | 437 case gdata::HTTP_INTERNAL_SERVER_ERROR: |
438 return DRIVE_FILE_ERROR_THROTTLED; | 438 return DRIVE_FILE_ERROR_THROTTLED; |
439 default: | 439 default: |
440 return DRIVE_FILE_ERROR_FAILED; | 440 return DRIVE_FILE_ERROR_FAILED; |
441 } | 441 } |
442 } | 442 } |
443 | 443 |
444 bool IsConnectionTypeCellular() { | 444 bool IsConnectionTypeCellular() { |
445 bool is_cellular = false; | 445 bool is_cellular = false; |
446 // Use switch, not if, to allow compiler to catch future enum changes. | 446 // Use switch, not if, to allow compiler to catch future enum changes. |
447 // (e.g. Addition of CONNECTION_5G) | 447 // (e.g. Addition of CONNECTION_5G) |
448 switch (net::NetworkChangeNotifier::GetConnectionType()) { | 448 switch (net::NetworkChangeNotifier::GetConnectionType()) { |
449 case net::NetworkChangeNotifier::CONNECTION_2G: | 449 case net::NetworkChangeNotifier::CONNECTION_2G: |
450 case net::NetworkChangeNotifier::CONNECTION_3G: | 450 case net::NetworkChangeNotifier::CONNECTION_3G: |
451 case net::NetworkChangeNotifier::CONNECTION_4G: | 451 case net::NetworkChangeNotifier::CONNECTION_4G: |
452 is_cellular = true; | 452 is_cellular = true; |
453 break; | 453 break; |
454 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: | 454 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: |
455 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: | 455 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: |
456 case net::NetworkChangeNotifier::CONNECTION_WIFI: | 456 case net::NetworkChangeNotifier::CONNECTION_WIFI: |
457 case net::NetworkChangeNotifier::CONNECTION_NONE: | 457 case net::NetworkChangeNotifier::CONNECTION_NONE: |
458 is_cellular = false; | 458 is_cellular = false; |
459 break; | 459 break; |
460 } | 460 } |
461 return is_cellular; | 461 return is_cellular; |
462 } | 462 } |
463 | 463 |
464 } // namespace util | 464 } // namespace util |
465 } // namespace gdata | 465 } // namespace drive |
OLD | NEW |