OLD | NEW |
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 "chrome/browser/extensions/api/messaging/message_property_provider.h" | 5 #include "chrome/browser/extensions/api/messaging/message_property_provider.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 void MessagePropertyProvider::GetChannelID(Profile* profile, | 30 void MessagePropertyProvider::GetChannelID(Profile* profile, |
31 const GURL& source_url, const ChannelIDCallback& reply) { | 31 const GURL& source_url, const ChannelIDCallback& reply) { |
32 if (!source_url.is_valid()) { | 32 if (!source_url.is_valid()) { |
33 // This isn't a real URL, so there's no sense in looking for a channel ID | 33 // This isn't a real URL, so there's no sense in looking for a channel ID |
34 // for it. Dispatch with an empty tls channel ID. | 34 // for it. Dispatch with an empty tls channel ID. |
35 reply.Run(std::string()); | 35 reply.Run(std::string()); |
36 return; | 36 return; |
37 } | 37 } |
38 scoped_refptr<net::URLRequestContextGetter> request_context_getter( | 38 scoped_refptr<net::URLRequestContextGetter> request_context_getter( |
39 profile->GetRequestContext()); | 39 profile->GetRequestContext()); |
40 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 40 content::BrowserThread::PostTask( |
41 base::Bind(&MessagePropertyProvider::GetChannelIDOnIOThread, | 41 content::BrowserThread::IO, FROM_HERE, |
42 base::ThreadTaskRunnerHandle::Get(), | 42 base::BindOnce(&MessagePropertyProvider::GetChannelIDOnIOThread, |
43 request_context_getter, | 43 base::ThreadTaskRunnerHandle::Get(), |
44 source_url.host(), | 44 request_context_getter, source_url.host(), reply)); |
45 reply)); | |
46 } | 45 } |
47 | 46 |
48 // Helper struct to bind the memory addresses that will be written to by | 47 // Helper struct to bind the memory addresses that will be written to by |
49 // ChannelIDService::GetChannelID to the callback provided to | 48 // ChannelIDService::GetChannelID to the callback provided to |
50 // MessagePropertyProvider::GetChannelID. | 49 // MessagePropertyProvider::GetChannelID. |
51 struct MessagePropertyProvider::GetChannelIDOutput { | 50 struct MessagePropertyProvider::GetChannelIDOutput { |
52 std::unique_ptr<crypto::ECPrivateKey> channel_id_key; | 51 std::unique_ptr<crypto::ECPrivateKey> channel_id_key; |
53 net::ChannelIDService::Request request; | 52 net::ChannelIDService::Request request; |
54 }; | 53 }; |
55 | 54 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 93 } |
95 base::StringPiece spki(reinterpret_cast<char*>(spki_vector.data()), | 94 base::StringPiece spki(reinterpret_cast<char*>(spki_vector.data()), |
96 spki_vector.size()); | 95 spki_vector.size()); |
97 base::DictionaryValue jwk_value; | 96 base::DictionaryValue jwk_value; |
98 if (!net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value)) { | 97 if (!net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value)) { |
99 original_task_runner->PostTask(FROM_HERE, no_tls_channel_id_closure); | 98 original_task_runner->PostTask(FROM_HERE, no_tls_channel_id_closure); |
100 return; | 99 return; |
101 } | 100 } |
102 std::string jwk_str; | 101 std::string jwk_str; |
103 base::JSONWriter::Write(jwk_value, &jwk_str); | 102 base::JSONWriter::Write(jwk_value, &jwk_str); |
104 original_task_runner->PostTask(FROM_HERE, base::Bind(reply, jwk_str)); | 103 original_task_runner->PostTask(FROM_HERE, base::BindOnce(reply, jwk_str)); |
105 } | 104 } |
106 | 105 |
107 } // namespace extensions | 106 } // namespace extensions |
OLD | NEW |