Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PARSE R_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PARSE R_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "chrome/common/extensions/dial_device_description_parser.mojom.h" | |
| 12 #include "chrome/common/media_router/dial_device_description.h" | |
| 13 #include "content/public/browser/utility_process_mojo_client.h" | |
| 14 | |
| 15 namespace media_router { | |
| 16 | |
| 17 // SafeDialDeviceDescriptionParser parses the given device description XML file | |
| 18 // safely via a utility process. This class runs on IO thread. | |
| 19 class SafeDialDeviceDescriptionParser | |
| 20 : 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.
| |
| 21 public: | |
| 22 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.
| |
| 23 base::Callback<void(bool, | |
| 24 const media_router::DialDeviceDescription&, | |
| 25 const std::string&)>; | |
| 26 | |
| 27 SafeDialDeviceDescriptionParser(); | |
| 28 | |
| 29 // Start parsing device description XML file in utility process. | |
| 30 void Start(const std::string& xml_text, | |
| 31 const DeviceDescriptionCallback& callback); | |
| 32 | |
| 33 private: | |
| 34 friend class base::RefCountedThreadSafe<SafeDialDeviceDescriptionParser>; | |
| 35 | |
| 36 ~SafeDialDeviceDescriptionParser(); | |
| 37 | |
| 38 // Notification from the utility process when it finishes parsing the | |
| 39 // 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.
| |
| 40 void ParseDialDeviceDescriptionDone( | |
| 41 bool result, | |
| 42 const media_router::DialDeviceDescription& device_description, | |
| 43 const std::string& logging_xml); | |
| 44 | |
| 45 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.
| |
| 46 | |
| 47 // Utility client used to send device description parsing task to the utility | |
| 48 // process. | |
| 49 std::unique_ptr<content::UtilityProcessMojoClient< | |
| 50 extensions::mojom::DialDeviceDescriptionParser>> | |
| 51 utility_process_mojo_client_; | |
| 52 | |
| 53 // Only accessed on the IO thread. | |
| 54 DeviceDescriptionCallback device_description_callback_; | |
| 55 | |
|
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.
| |
| 56 DISALLOW_COPY_AND_ASSIGN(SafeDialDeviceDescriptionParser); | |
| 57 }; | |
| 58 | |
| 59 } // namespace media_router | |
| 60 | |
| 61 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PA RSER_H_ | |
| OLD | NEW |