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

Side by Side Diff: chrome/browser/extensions/api/messaging/message_property_provider.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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_messages_apitest.cc » ('j') | 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 "chrome/browser/extensions/api/messaging/message_property_provider.h" 5 #include "chrome/browser/extensions/api/messaging/message_property_provider.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 30 matching lines...) Expand all
41 request_context_getter, 41 request_context_getter,
42 source_url.host(), 42 source_url.host(),
43 reply)); 43 reply));
44 } 44 }
45 45
46 // Helper struct to bind the memory addresses that will be written to by 46 // Helper struct to bind the memory addresses that will be written to by
47 // ChannelIDService::GetChannelID to the callback provided to 47 // ChannelIDService::GetChannelID to the callback provided to
48 // MessagePropertyProvider::GetChannelID. 48 // MessagePropertyProvider::GetChannelID.
49 struct MessagePropertyProvider::GetChannelIDOutput { 49 struct MessagePropertyProvider::GetChannelIDOutput {
50 scoped_ptr<crypto::ECPrivateKey> channel_id_key; 50 scoped_ptr<crypto::ECPrivateKey> channel_id_key;
51 net::ChannelIDService::RequestHandle request_handle; 51 net::ChannelIDService::Request request;
52 }; 52 };
53 53
54 // static 54 // static
55 void MessagePropertyProvider::GetChannelIDOnIOThread( 55 void MessagePropertyProvider::GetChannelIDOnIOThread(
56 scoped_refptr<base::TaskRunner> original_task_runner, 56 scoped_refptr<base::TaskRunner> original_task_runner,
57 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 57 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
58 const std::string& host, 58 const std::string& host,
59 const ChannelIDCallback& reply) { 59 const ChannelIDCallback& reply) {
60 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 60 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
61 net::ChannelIDService* channel_id_service = 61 net::ChannelIDService* channel_id_service =
62 request_context_getter->GetURLRequestContext()-> 62 request_context_getter->GetURLRequestContext()->
63 channel_id_service(); 63 channel_id_service();
64 GetChannelIDOutput* output = new GetChannelIDOutput(); 64 GetChannelIDOutput* output = new GetChannelIDOutput();
65 net::CompletionCallback net_completion_callback = 65 net::CompletionCallback net_completion_callback =
66 base::Bind(&MessagePropertyProvider::GotChannelID, 66 base::Bind(&MessagePropertyProvider::GotChannelID,
67 original_task_runner, 67 original_task_runner,
68 base::Owned(output), 68 base::Owned(output),
69 reply); 69 reply);
70 int status = channel_id_service->GetChannelID(host, &output->channel_id_key, 70 int status = channel_id_service->GetChannelID(
71 net_completion_callback, 71 host, &output->channel_id_key, net_completion_callback, &output->request);
72 &output->request_handle);
73 if (status == net::ERR_IO_PENDING) 72 if (status == net::ERR_IO_PENDING)
74 return; 73 return;
75 GotChannelID(original_task_runner, output, reply, status); 74 GotChannelID(original_task_runner, output, reply, status);
76 } 75 }
77 76
78 // static 77 // static
79 void MessagePropertyProvider::GotChannelID( 78 void MessagePropertyProvider::GotChannelID(
80 scoped_refptr<base::TaskRunner> original_task_runner, 79 scoped_refptr<base::TaskRunner> original_task_runner,
81 struct GetChannelIDOutput* output, 80 struct GetChannelIDOutput* output,
82 const ChannelIDCallback& reply, 81 const ChannelIDCallback& reply,
(...skipping 14 matching lines...) Expand all
97 if (!net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value)) { 96 if (!net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value)) {
98 original_task_runner->PostTask(FROM_HERE, no_tls_channel_id_closure); 97 original_task_runner->PostTask(FROM_HERE, no_tls_channel_id_closure);
99 return; 98 return;
100 } 99 }
101 std::string jwk_str; 100 std::string jwk_str;
102 base::JSONWriter::Write(jwk_value, &jwk_str); 101 base::JSONWriter::Write(jwk_value, &jwk_str);
103 original_task_runner->PostTask(FROM_HERE, base::Bind(reply, jwk_str)); 102 original_task_runner->PostTask(FROM_HERE, base::Bind(reply, jwk_str));
104 } 103 }
105 104
106 } // namespace extensions 105 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_messages_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698