OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/media/router/discovery/dial/safe_dial_device_descriptio n_parser.h" | 5 #include "chrome/browser/media/router/discovery/dial/safe_dial_device_descriptio n_parser.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | |
10 #include "base/callback_helpers.h" | |
9 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
10 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
11 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
12 | 14 |
13 namespace media_router { | 15 namespace media_router { |
14 | 16 |
15 SafeDialDeviceDescriptionParser::SafeDialDeviceDescriptionParser() {} | 17 SafeDialDeviceDescriptionParser::SafeDialDeviceDescriptionParser() {} |
16 | 18 |
17 SafeDialDeviceDescriptionParser::~SafeDialDeviceDescriptionParser() {} | 19 SafeDialDeviceDescriptionParser::~SafeDialDeviceDescriptionParser() {} |
18 | 20 |
19 void SafeDialDeviceDescriptionParser::Start( | 21 void SafeDialDeviceDescriptionParser::Start( |
20 const std::string& xml_text, | 22 const std::string& xml_text, |
21 const DeviceDescriptionCallback& callback) { | 23 DeviceDescriptionCallback callback) { |
mark a. foltz
2017/05/09 22:28:44
Can this just be a base::RepeatingCallback instead
tzik
2017/05/11 09:00:30
So, the callback is not from Mojo-generated code?
zhaobin
2017/05/11 17:38:57
The callback is from mojo-generated code.
using
tzik
2017/05/15 06:28:15
Right, the callback type was from Mojo. But, as th
| |
22 DVLOG(2) << "Start parsing device description..."; | 24 DVLOG(2) << "Start parsing device description..."; |
23 DCHECK(thread_checker_.CalledOnValidThread()); | 25 DCHECK(thread_checker_.CalledOnValidThread()); |
24 | 26 |
25 DCHECK(callback); | 27 DCHECK(callback); |
28 auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback)); | |
26 | 29 |
27 if (!utility_process_mojo_client_) { | 30 if (!utility_process_mojo_client_) { |
28 DVLOG(2) << "Start utility process in background..."; | 31 DVLOG(2) << "Start utility process in background..."; |
29 utility_process_mojo_client_ = | 32 utility_process_mojo_client_ = |
30 base::MakeUnique<content::UtilityProcessMojoClient< | 33 base::MakeUnique<content::UtilityProcessMojoClient< |
31 chrome::mojom::DialDeviceDescriptionParser>>( | 34 chrome::mojom::DialDeviceDescriptionParser>>( |
32 l10n_util::GetStringUTF16( | 35 l10n_util::GetStringUTF16( |
33 IDS_UTILITY_PROCESS_DIAL_DEVICE_DESCRIPTION_PARSER_NAME)); | 36 IDS_UTILITY_PROCESS_DIAL_DEVICE_DESCRIPTION_PARSER_NAME)); |
34 | 37 |
35 utility_process_mojo_client_->set_error_callback( | 38 utility_process_mojo_client_->set_error_callback( |
36 base::Bind(callback, nullptr)); | 39 base::Bind(copyable_callback, nullptr)); |
37 | 40 |
38 // This starts utility process in the background. | 41 // This starts utility process in the background. |
39 utility_process_mojo_client_->Start(); | 42 utility_process_mojo_client_->Start(); |
40 } | 43 } |
41 | 44 |
42 // This call is queued up until the Mojo message pipe has been established to | 45 // This call is queued up until the Mojo message pipe has been established to |
43 // the service running in the utility process. | 46 // the service running in the utility process. |
44 utility_process_mojo_client_->service()->ParseDialDeviceDescription(xml_text, | 47 utility_process_mojo_client_->service()->ParseDialDeviceDescription( |
45 callback); | 48 xml_text, copyable_callback); |
46 } | 49 } |
47 | 50 |
48 } // namespace media_router | 51 } // namespace media_router |
OLD | NEW |