OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/media/media_stream_device_settings.h" | 5 #include "content/browser/renderer_host/media/media_stream_device_settings.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 class ResponseCallbackHelper | 36 class ResponseCallbackHelper |
37 : public base::RefCountedThreadSafe<ResponseCallbackHelper> { | 37 : public base::RefCountedThreadSafe<ResponseCallbackHelper> { |
38 public: | 38 public: |
39 explicit ResponseCallbackHelper( | 39 explicit ResponseCallbackHelper( |
40 base::WeakPtr<media_stream::MediaStreamDeviceSettings> settings) | 40 base::WeakPtr<media_stream::MediaStreamDeviceSettings> settings) |
41 : settings_(settings) { | 41 : settings_(settings) { |
42 } | 42 } |
43 | 43 |
44 void PostResponse(const std::string& label, | 44 void PostResponse(const std::string& label, |
45 const content::MediaStreamDevices& devices) { | 45 const content::MediaStreamDevices& devices) { |
46 if (!settings_) | |
tommi (sloooow) - chröme
2012/07/18 08:15:23
it's better to do this check only on the IO thread
no longer working on chromium
2012/07/18 09:39:28
But can BrowserThread::PostTask(BrowserThread::IO,
| |
47 return; | |
48 | |
46 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 49 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
47 BrowserThread::PostTask( | 50 BrowserThread::PostTask( |
48 BrowserThread::IO, FROM_HERE, | 51 BrowserThread::IO, FROM_HERE, |
49 base::Bind(&media_stream::MediaStreamDeviceSettings::PostResponse, | 52 base::Bind(&media_stream::MediaStreamDeviceSettings::PostResponse, |
50 settings_, label, devices)); | 53 settings_, label, devices)); |
51 return; | 54 return; |
52 } else if (settings_) { | |
53 settings_->PostResponse(label, devices); | |
54 } | 55 } |
56 | |
57 settings_->PostResponse(label, devices); | |
55 } | 58 } |
56 | 59 |
57 private: | 60 private: |
58 friend class base::RefCountedThreadSafe<ResponseCallbackHelper>; | 61 friend class base::RefCountedThreadSafe<ResponseCallbackHelper>; |
59 ~ResponseCallbackHelper() {} | 62 ~ResponseCallbackHelper() {} |
60 | 63 |
61 base::WeakPtr<media_stream::MediaStreamDeviceSettings> settings_; | 64 base::WeakPtr<media_stream::MediaStreamDeviceSettings> settings_; |
62 | 65 |
63 DISALLOW_COPY_AND_ASSIGN(ResponseCallbackHelper); | 66 DISALLOW_COPY_AND_ASSIGN(ResponseCallbackHelper); |
64 }; | 67 }; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 content::MediaResponseCallback callback = | 368 content::MediaResponseCallback callback = |
366 base::Bind(&ResponseCallbackHelper::PostResponse, | 369 base::Bind(&ResponseCallbackHelper::PostResponse, |
367 helper.get(), label); | 370 helper.get(), label); |
368 | 371 |
369 BrowserThread::PostTask( | 372 BrowserThread::PostTask( |
370 BrowserThread::UI, FROM_HERE, | 373 BrowserThread::UI, FROM_HERE, |
371 base::Bind(&DoDeviceRequest, *request, callback)); | 374 base::Bind(&DoDeviceRequest, *request, callback)); |
372 } | 375 } |
373 | 376 |
374 } // namespace media_stream | 377 } // namespace media_stream |
OLD | NEW |