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

Side by Side Diff: chrome/browser/extensions/extension_messages_apitest.cc

Issue 1149083013: Combine ChannelIDService::RequestHandle and ChannelIDServiceRequest classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove new test case and combine it with existing one Created 5 years, 6 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 // 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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 public ExternallyConnectableMessagingTest { 967 public ExternallyConnectableMessagingTest {
968 public: 968 public:
969 ExternallyConnectableMessagingWithTlsChannelIdTest() 969 ExternallyConnectableMessagingWithTlsChannelIdTest()
970 : tls_channel_id_created_(false, false) { 970 : tls_channel_id_created_(false, false) {
971 } 971 }
972 972
973 std::string CreateTlsChannelId() { 973 std::string CreateTlsChannelId() {
974 scoped_refptr<net::URLRequestContextGetter> request_context_getter( 974 scoped_refptr<net::URLRequestContextGetter> request_context_getter(
975 profile()->GetRequestContext()); 975 profile()->GetRequestContext());
976 scoped_ptr<crypto::ECPrivateKey> channel_id_key; 976 scoped_ptr<crypto::ECPrivateKey> channel_id_key;
977 net::ChannelIDService::RequestHandle request_handle; 977 net::ChannelIDService::Request request;
978 content::BrowserThread::PostTask( 978 content::BrowserThread::PostTask(
979 content::BrowserThread::IO, FROM_HERE, 979 content::BrowserThread::IO, FROM_HERE,
980 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest:: 980 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest::
981 CreateDomainBoundCertOnIOThread, 981 CreateDomainBoundCertOnIOThread,
982 base::Unretained(this), base::Unretained(&channel_id_key), 982 base::Unretained(this), base::Unretained(&channel_id_key),
983 base::Unretained(&request_handle), request_context_getter)); 983 base::Unretained(&request), request_context_getter));
984 tls_channel_id_created_.Wait(); 984 tls_channel_id_created_.Wait();
985 // Create the expected value. 985 // Create the expected value.
986 std::vector<uint8> spki_vector; 986 std::vector<uint8> spki_vector;
987 if (!channel_id_key->ExportPublicKey(&spki_vector)) 987 if (!channel_id_key->ExportPublicKey(&spki_vector))
988 return std::string(); 988 return std::string();
989 base::StringPiece spki(reinterpret_cast<char*>( 989 base::StringPiece spki(reinterpret_cast<char*>(
990 vector_as_array(&spki_vector)), spki_vector.size()); 990 vector_as_array(&spki_vector)), spki_vector.size());
991 base::DictionaryValue jwk_value; 991 base::DictionaryValue jwk_value;
992 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value); 992 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value);
993 std::string tls_channel_id_value; 993 std::string tls_channel_id_value;
994 base::JSONWriter::Write(jwk_value, &tls_channel_id_value); 994 base::JSONWriter::Write(jwk_value, &tls_channel_id_value);
995 return tls_channel_id_value; 995 return tls_channel_id_value;
996 } 996 }
997 997
998 private: 998 private:
999 void CreateDomainBoundCertOnIOThread( 999 void CreateDomainBoundCertOnIOThread(
1000 scoped_ptr<crypto::ECPrivateKey>* channel_id_key, 1000 scoped_ptr<crypto::ECPrivateKey>* channel_id_key,
1001 net::ChannelIDService::RequestHandle* request_handle, 1001 net::ChannelIDService::Request* request,
1002 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { 1002 scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
1003 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 1003 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
1004 net::ChannelIDService* channel_id_service = 1004 net::ChannelIDService* channel_id_service =
1005 request_context_getter->GetURLRequestContext()-> 1005 request_context_getter->GetURLRequestContext()->
1006 channel_id_service(); 1006 channel_id_service();
1007 int status = channel_id_service->GetOrCreateChannelID( 1007 int status = channel_id_service->GetOrCreateChannelID(
1008 chromium_org_url().host(), channel_id_key, 1008 chromium_org_url().host(), channel_id_key,
1009 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest:: 1009 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest::
1010 GotDomainBoundCert, 1010 GotDomainBoundCert,
1011 base::Unretained(this)), 1011 base::Unretained(this)),
1012 request_handle); 1012 request);
1013 if (status == net::ERR_IO_PENDING) 1013 if (status == net::ERR_IO_PENDING)
1014 return; 1014 return;
1015 GotDomainBoundCert(status); 1015 GotDomainBoundCert(status);
1016 } 1016 }
1017 1017
1018 void GotDomainBoundCert(int status) { 1018 void GotDomainBoundCert(int status) {
1019 ASSERT_TRUE(status == net::OK); 1019 ASSERT_TRUE(status == net::OK);
1020 tls_channel_id_created_.Signal(); 1020 tls_channel_id_created_.Signal();
1021 } 1021 }
1022 1022
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); 1194 ui_test_utils::NavigateToURL(browser(), chromium_org_url());
1195 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, 1195 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR,
1196 CanConnectAndSendMessagesToMainFrame(invalid.get())); 1196 CanConnectAndSendMessagesToMainFrame(invalid.get()));
1197 } 1197 }
1198 1198
1199 #endif // !defined(OS_WIN) - http://crbug.com/350517. 1199 #endif // !defined(OS_WIN) - http://crbug.com/350517.
1200 1200
1201 } // namespace 1201 } // namespace
1202 1202
1203 }; // namespace extensions 1203 }; // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/messaging/message_property_provider.cc ('k') | net/quic/crypto/channel_id_chromium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698