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

Side by Side Diff: url/url_util.cc

Issue 2661543003: Introduce the concept of web schemes capable of storage (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
« no previous file with comments | « url/url_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "url/url_util.h" 5 #include "url/url_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 kJavaScriptScheme, 66 kJavaScriptScheme,
67 kDataScheme, 67 kDataScheme,
68 }; 68 };
69 69
70 const char* kCORSEnabledSchemes[] = { 70 const char* kCORSEnabledSchemes[] = {
71 kHttpScheme, 71 kHttpScheme,
72 kHttpsScheme, 72 kHttpsScheme,
73 kDataScheme, 73 kDataScheme,
74 }; 74 };
75 75
76 const char* kWebStorageSchemes[] = {
77 kHttpScheme,
78 kHttpsScheme,
79 kFileScheme,
80 kFtpScheme,
81 kWsScheme,
82 kWssScheme,
83 };
84
76 bool initialized = false; 85 bool initialized = false;
77 86
78 // Lists of the currently installed standard and referrer schemes. These lists 87 // Lists of the currently installed standard and referrer schemes. These lists
79 // are lazily initialized by Initialize and are leaked on shutdown to prevent 88 // are lazily initialized by Initialize and are leaked on shutdown to prevent
80 // any destructors from being called that will slow us down or cause problems. 89 // any destructors from being called that will slow us down or cause problems.
81 std::vector<SchemeWithType>* standard_schemes = nullptr; 90 std::vector<SchemeWithType>* standard_schemes = nullptr;
82 std::vector<SchemeWithType>* referrer_schemes = nullptr; 91 std::vector<SchemeWithType>* referrer_schemes = nullptr;
83 92
84 // Similar to above, initialized by the Init*Schemes methods. 93 // Similar to above, initialized by the Init*Schemes methods.
85 std::vector<std::string>* secure_schemes = nullptr; 94 std::vector<std::string>* secure_schemes = nullptr;
86 std::vector<std::string>* local_schemes = nullptr; 95 std::vector<std::string>* local_schemes = nullptr;
87 std::vector<std::string>* no_access_schemes = nullptr; 96 std::vector<std::string>* no_access_schemes = nullptr;
88 std::vector<std::string>* cors_enabled_schemes = nullptr; 97 std::vector<std::string>* cors_enabled_schemes = nullptr;
98 std::vector<std::string>* web_storage_schemes = nullptr;
89 99
90 // See the LockSchemeRegistries declaration in the header. 100 // See the LockSchemeRegistries declaration in the header.
91 bool scheme_registries_locked = false; 101 bool scheme_registries_locked = false;
92 102
93 // This template converts a given character type to the corresponding 103 // This template converts a given character type to the corresponding
94 // StringPiece type. 104 // StringPiece type.
95 template<typename CHAR> struct CharToStringPiece { 105 template<typename CHAR> struct CharToStringPiece {
96 }; 106 };
97 template<> struct CharToStringPiece<char> { 107 template<> struct CharToStringPiece<char> {
98 typedef base::StringPiece Piece; 108 typedef base::StringPiece Piece;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 InitSchemesWithType(&standard_schemes, kStandardURLSchemes, 517 InitSchemesWithType(&standard_schemes, kStandardURLSchemes,
508 arraysize(kStandardURLSchemes)); 518 arraysize(kStandardURLSchemes));
509 InitSchemesWithType(&referrer_schemes, kReferrerURLSchemes, 519 InitSchemesWithType(&referrer_schemes, kReferrerURLSchemes,
510 arraysize(kReferrerURLSchemes)); 520 arraysize(kReferrerURLSchemes));
511 InitSchemes(&secure_schemes, kSecureSchemes, arraysize(kSecureSchemes)); 521 InitSchemes(&secure_schemes, kSecureSchemes, arraysize(kSecureSchemes));
512 InitSchemes(&local_schemes, kLocalSchemes, arraysize(kLocalSchemes)); 522 InitSchemes(&local_schemes, kLocalSchemes, arraysize(kLocalSchemes));
513 InitSchemes(&no_access_schemes, kNoAccessSchemes, 523 InitSchemes(&no_access_schemes, kNoAccessSchemes,
514 arraysize(kNoAccessSchemes)); 524 arraysize(kNoAccessSchemes));
515 InitSchemes(&cors_enabled_schemes, kCORSEnabledSchemes, 525 InitSchemes(&cors_enabled_schemes, kCORSEnabledSchemes,
516 arraysize(kCORSEnabledSchemes)); 526 arraysize(kCORSEnabledSchemes));
527 InitSchemes(&web_storage_schemes, kWebStorageSchemes,
528 arraysize(kWebStorageSchemes));
517 initialized = true; 529 initialized = true;
518 } 530 }
519 531
520 void Shutdown() { 532 void Shutdown() {
521 initialized = false; 533 initialized = false;
522 delete standard_schemes; 534 delete standard_schemes;
523 standard_schemes = nullptr; 535 standard_schemes = nullptr;
524 delete referrer_schemes; 536 delete referrer_schemes;
525 referrer_schemes = nullptr; 537 referrer_schemes = nullptr;
526 delete secure_schemes; 538 delete secure_schemes;
527 secure_schemes = nullptr; 539 secure_schemes = nullptr;
528 delete local_schemes; 540 delete local_schemes;
529 local_schemes = nullptr; 541 local_schemes = nullptr;
530 delete no_access_schemes; 542 delete no_access_schemes;
531 no_access_schemes = nullptr; 543 no_access_schemes = nullptr;
532 delete cors_enabled_schemes; 544 delete cors_enabled_schemes;
533 cors_enabled_schemes = nullptr; 545 cors_enabled_schemes = nullptr;
546 delete web_storage_schemes;
547 web_storage_schemes = nullptr;
534 } 548 }
535 549
536 void AddStandardScheme(const char* new_scheme, SchemeType type) { 550 void AddStandardScheme(const char* new_scheme, SchemeType type) {
537 Initialize(); 551 Initialize();
538 DoAddSchemeWithType(new_scheme, type, standard_schemes); 552 DoAddSchemeWithType(new_scheme, type, standard_schemes);
539 } 553 }
540 554
541 void AddReferrerScheme(const char* new_scheme, SchemeType type) { 555 void AddReferrerScheme(const char* new_scheme, SchemeType type) {
542 Initialize(); 556 Initialize();
543 DoAddSchemeWithType(new_scheme, type, referrer_schemes); 557 DoAddSchemeWithType(new_scheme, type, referrer_schemes);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 void AddCORSEnabledScheme(const char* new_scheme) { 590 void AddCORSEnabledScheme(const char* new_scheme) {
577 Initialize(); 591 Initialize();
578 DoAddScheme(new_scheme, cors_enabled_schemes); 592 DoAddScheme(new_scheme, cors_enabled_schemes);
579 } 593 }
580 594
581 const std::vector<std::string>& GetCORSEnabledSchemes() { 595 const std::vector<std::string>& GetCORSEnabledSchemes() {
582 Initialize(); 596 Initialize();
583 return *cors_enabled_schemes; 597 return *cors_enabled_schemes;
584 } 598 }
585 599
600 void AddWebStorageScheme(const char* new_scheme) {
601 Initialize();
602 DoAddScheme(new_scheme, web_storage_schemes);
603 }
604
605 const std::vector<std::string>& GetWebStorageSchemes() {
606 Initialize();
607 return *web_storage_schemes;
608 }
609
586 void LockSchemeRegistries() { 610 void LockSchemeRegistries() {
587 scheme_registries_locked = true; 611 scheme_registries_locked = true;
588 } 612 }
589 613
590 bool IsStandard(const char* spec, const Component& scheme) { 614 bool IsStandard(const char* spec, const Component& scheme) {
591 SchemeType unused_scheme_type; 615 SchemeType unused_scheme_type;
592 return DoIsStandard(spec, scheme, &unused_scheme_type); 616 return DoIsStandard(spec, scheme, &unused_scheme_type);
593 } 617 }
594 618
595 bool GetStandardSchemeType(const char* spec, 619 bool GetStandardSchemeType(const char* spec,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 return DoCompareSchemeComponent(spec, component, compare_to); 841 return DoCompareSchemeComponent(spec, component, compare_to);
818 } 842 }
819 843
820 bool CompareSchemeComponent(const base::char16* spec, 844 bool CompareSchemeComponent(const base::char16* spec,
821 const Component& component, 845 const Component& component,
822 const char* compare_to) { 846 const char* compare_to) {
823 return DoCompareSchemeComponent(spec, component, compare_to); 847 return DoCompareSchemeComponent(spec, component, compare_to);
824 } 848 }
825 849
826 } // namespace url 850 } // namespace url
OLDNEW
« no previous file with comments | « url/url_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698