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

Side by Side Diff: chrome/browser/media/router/media_router_mojo_impl.h

Issue 1821823002: [Media Router] Conditionally enable mDNS on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments, build, and removing move Created 4 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <map> 11 #include <map>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
17 #include "base/containers/scoped_ptr_hash_map.h" 17 #include "base/containers/scoped_ptr_hash_map.h"
18 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/observer_list.h" 22 #include "base/observer_list.h"
23 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
24 #include "build/build_config.h"
24 #include "chrome/browser/media/router/issue.h" 25 #include "chrome/browser/media/router/issue.h"
25 #include "chrome/browser/media/router/issue_manager.h" 26 #include "chrome/browser/media/router/issue_manager.h"
26 #include "chrome/browser/media/router/media_router.mojom.h" 27 #include "chrome/browser/media/router/media_router.mojom.h"
27 #include "chrome/browser/media/router/media_router_base.h" 28 #include "chrome/browser/media/router/media_router_base.h"
28 #include "chrome/browser/media/router/media_routes_observer.h" 29 #include "chrome/browser/media/router/media_routes_observer.h"
29 #include "mojo/public/cpp/bindings/binding.h" 30 #include "mojo/public/cpp/bindings/binding.h"
30 31
31 namespace content { 32 namespace content {
32 class BrowserContext; 33 class BrowserContext;
33 } 34 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void DetachRoute(const MediaRoute::Id& route_id) override; 92 void DetachRoute(const MediaRoute::Id& route_id) override;
92 void SendRouteMessage(const MediaRoute::Id& route_id, 93 void SendRouteMessage(const MediaRoute::Id& route_id,
93 const std::string& message, 94 const std::string& message,
94 const SendRouteMessageCallback& callback) override; 95 const SendRouteMessageCallback& callback) override;
95 void SendRouteBinaryMessage( 96 void SendRouteBinaryMessage(
96 const MediaRoute::Id& route_id, 97 const MediaRoute::Id& route_id,
97 scoped_ptr<std::vector<uint8_t>> data, 98 scoped_ptr<std::vector<uint8_t>> data,
98 const SendRouteMessageCallback& callback) override; 99 const SendRouteMessageCallback& callback) override;
99 void AddIssue(const Issue& issue) override; 100 void AddIssue(const Issue& issue) override;
100 void ClearIssue(const Issue::Id& issue_id) override; 101 void ClearIssue(const Issue::Id& issue_id) override;
102 bool should_enable_mdns_discovery() const override;
103 void EnsureMdnsDiscoveryEnabled() override;
101 104
102 const std::string& media_route_provider_extension_id() const { 105 const std::string& media_route_provider_extension_id() const {
103 return media_route_provider_extension_id_; 106 return media_route_provider_extension_id_;
104 } 107 }
105 108
106 void set_instance_id_for_test(const std::string& instance_id) { 109 void set_instance_id_for_test(const std::string& instance_id) {
107 instance_id_ = instance_id; 110 instance_id_ = instance_id;
108 } 111 }
109 112
110 private: 113 private:
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 const SendRouteMessageCallback& callback); 247 const SendRouteMessageCallback& callback);
245 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, 248 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id,
246 scoped_ptr<std::vector<uint8_t>> data, 249 scoped_ptr<std::vector<uint8_t>> data,
247 const SendRouteMessageCallback& callback); 250 const SendRouteMessageCallback& callback);
248 void DoListenForRouteMessages(const MediaRoute::Id& route_id); 251 void DoListenForRouteMessages(const MediaRoute::Id& route_id);
249 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); 252 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id);
250 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); 253 void DoStartObservingMediaSinks(const MediaSource::Id& source_id);
251 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); 254 void DoStopObservingMediaSinks(const MediaSource::Id& source_id);
252 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); 255 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id);
253 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); 256 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id);
257 void DoEnsureMdnsDiscoveryEnabled();
254 258
255 // Invoked when the next batch of messages arrives. 259 // Invoked when the next batch of messages arrives.
256 // |route_id|: ID of route of the messages. 260 // |route_id|: ID of route of the messages.
257 // |messages|: A list of messages received. 261 // |messages|: A list of messages received.
258 // |error|: true if an error occurred. 262 // |error|: true if an error occurred.
259 void OnRouteMessagesReceived( 263 void OnRouteMessagesReceived(
260 const MediaRoute::Id& route_id, 264 const MediaRoute::Id& route_id,
261 mojo::Array<interfaces::RouteMessagePtr> messages, 265 mojo::Array<interfaces::RouteMessagePtr> messages,
262 bool error); 266 bool error);
263 267
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 void AttemptWakeEventPage(); 317 void AttemptWakeEventPage();
314 318
315 // Sets the reason why we are attempting to wake the extension. Since 319 // Sets the reason why we are attempting to wake the extension. Since
316 // multiple tasks may be enqueued for execution each time the extension runs, 320 // multiple tasks may be enqueued for execution each time the extension runs,
317 // we record the first such reason. 321 // we record the first such reason.
318 void SetWakeReason(MediaRouteProviderWakeReason reason); 322 void SetWakeReason(MediaRouteProviderWakeReason reason);
319 323
320 // Clears the wake reason after the extension has been awoken. 324 // Clears the wake reason after the extension has been awoken.
321 void ClearWakeReason(); 325 void ClearWakeReason();
322 326
327 void EnableMdnsFromFirewallCheck(bool firewall_can_use_local_ports);
328
323 // Pending requests queued to be executed once component extension 329 // Pending requests queued to be executed once component extension
324 // becomes ready. 330 // becomes ready.
325 std::deque<base::Closure> pending_requests_; 331 std::deque<base::Closure> pending_requests_;
326 332
327 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> 333 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>>
328 sinks_queries_; 334 sinks_queries_;
329 335
330 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> 336 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>>
331 routes_queries_; 337 routes_queries_;
332 338
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 int wakeup_attempt_count_ = 0; 380 int wakeup_attempt_count_ = 0;
375 381
376 // Records the current reason the extension is being woken up. Is set to 382 // Records the current reason the extension is being woken up. Is set to
377 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. 383 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason.
378 MediaRouteProviderWakeReason current_wake_reason_; 384 MediaRouteProviderWakeReason current_wake_reason_;
379 385
380 // A flag to ensure that we record the provider version once, during the 386 // A flag to ensure that we record the provider version once, during the
381 // initial event page wakeup attempt. 387 // initial event page wakeup attempt.
382 bool provider_version_was_recorded_ = false; 388 bool provider_version_was_recorded_ = false;
383 389
390 // A flag to ensure that mDNS discovery is only enabled on Windows when there
391 // will be appropriate context for the user to associate a firewall prompt
392 // with Media Router. This can be set to |true| earlier if we know that a
393 // prompt will not occur.
394 #if defined(OS_WIN)
395 bool should_enable_mdns_discovery_ = false;
396 #else
397 bool should_enable_mdns_discovery_ = true;
398 #endif
399
384 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 400 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
385 401
386 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 402 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
387 }; 403 };
388 404
389 } // namespace media_router 405 } // namespace media_router
390 406
391 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 407 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698