Chromium Code Reviews| Index: chrome/browser/media/router/discovery/safe_dial_device_description_parser.h |
| diff --git a/chrome/browser/media/router/discovery/safe_dial_device_description_parser.h b/chrome/browser/media/router/discovery/safe_dial_device_description_parser.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b81aa9bd24bd9213dee3382d8ed90b4a561af8cc |
| --- /dev/null |
| +++ b/chrome/browser/media/router/discovery/safe_dial_device_description_parser.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PARSER_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PARSER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/common/extensions/dial_device_description_parser.mojom.h" |
| +#include "chrome/common/media_router/dial_device_description.h" |
| +#include "content/public/browser/utility_process_mojo_client.h" |
| + |
| +namespace media_router { |
| + |
| +// SafeDialDeviceDescriptionParser parses the given device description XML file |
| +// safely via a utility process. This class runs on IO thread. |
| +class SafeDialDeviceDescriptionParser |
| + : public base::RefCountedThreadSafe<SafeDialDeviceDescriptionParser> { |
|
mark a. foltz
2017/03/17 19:05:46
If this is used *only* on the IO thread I think th
zhaobin
2017/03/18 00:17:38
Done.
|
| + public: |
| + using DeviceDescriptionCallback = |
|
mark a. foltz
2017/03/17 19:05:46
Document the parameters here (especially the first
zhaobin
2017/03/18 00:17:38
Done.
|
| + base::Callback<void(bool, |
| + const media_router::DialDeviceDescription&, |
| + const std::string&)>; |
| + |
| + SafeDialDeviceDescriptionParser(); |
| + |
| + // Start parsing device description XML file in utility process. |
| + void Start(const std::string& xml_text, |
| + const DeviceDescriptionCallback& callback); |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<SafeDialDeviceDescriptionParser>; |
| + |
| + ~SafeDialDeviceDescriptionParser(); |
| + |
| + // Notification from the utility process when it finishes parsing the |
| + // device description XML. Runs on IO thread. |
|
mark a. foltz
2017/03/17 19:05:46
Please document the meanings of |result| and |logg
zhaobin
2017/03/18 00:17:38
Done.
|
| + void ParseDialDeviceDescriptionDone( |
| + bool result, |
| + const media_router::DialDeviceDescription& device_description, |
| + const std::string& logging_xml); |
| + |
| + void ParseDialDeviceDescriptionFailed(); |
|
mark a. foltz
2017/03/17 19:05:46
Can this take an enum describing the reason why it
zhaobin
2017/03/18 00:17:38
Done.
|
| + |
| + // Utility client used to send device description parsing task to the utility |
| + // process. |
| + std::unique_ptr<content::UtilityProcessMojoClient< |
| + extensions::mojom::DialDeviceDescriptionParser>> |
| + utility_process_mojo_client_; |
| + |
| + // Only accessed on the IO thread. |
| + DeviceDescriptionCallback device_description_callback_; |
| + |
|
mark a. foltz
2017/03/17 19:05:46
Add a base::ThreadChecker to enforce thread safety
zhaobin
2017/03/18 00:17:38
Done.
|
| + DISALLOW_COPY_AND_ASSIGN(SafeDialDeviceDescriptionParser); |
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PARSER_H_ |