Remove deprecated API usages
This commit is contained in:
parent
785bc2986b
commit
51368952a2
4 changed files with 11 additions and 15 deletions
|
@ -1,15 +1,13 @@
|
|||
ipc = require 'ipc'
|
||||
{ipcMain} = require 'electron'
|
||||
{desktopCapturer} = process.atomBinding 'desktop_capturer'
|
||||
|
||||
# The browser module manages all desktop-capturer moduels in renderer process.
|
||||
desktopCapturer = process.atomBinding('desktop_capturer').desktopCapturer
|
||||
|
||||
isOptionsEqual = (opt1, opt2) ->
|
||||
deepEqual = (opt1, opt2) ->
|
||||
return JSON.stringify(opt1) is JSON.stringify(opt2)
|
||||
|
||||
# A queue for holding all requests from renderer process.
|
||||
requestsQueue = []
|
||||
|
||||
ipc.on 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', (event, options, id) ->
|
||||
ipcMain.on 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', (event, options, id) ->
|
||||
request = { id: id, options: options, webContents: event.sender }
|
||||
requestsQueue.push request
|
||||
desktopCapturer.startHandling options if requestsQueue.length is 1
|
||||
|
@ -29,7 +27,7 @@ desktopCapturer.emit = (event_name, event, error_message, sources) ->
|
|||
# it for reducing redunplicated `desktopCaptuer.startHandling` calls.
|
||||
unhandledRequestsQueue = []
|
||||
for request in requestsQueue
|
||||
if isOptionsEqual handledRequest.options, request.options
|
||||
if deepEqual handledRequest.options, request.options
|
||||
request.webContents?.send "ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_#{request.id}", error_message, result
|
||||
else
|
||||
unhandledRequestsQueue.push request
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
ipc = require 'ipc'
|
||||
NativeImage = require 'native-image'
|
||||
{ipcRenderer, NativeImage} = require 'electron'
|
||||
|
||||
nextId = 0
|
||||
getNextId = -> ++nextId
|
||||
|
||||
getSources = (options, callback) ->
|
||||
exports.getSources = (options, callback) ->
|
||||
id = getNextId()
|
||||
ipc.send 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options, id
|
||||
ipc.once "ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_#{id}", (error_message, sources) ->
|
||||
ipcRenderer.send 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options, id
|
||||
ipcRenderer.once "ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_#{id}", (error_message, sources) ->
|
||||
error = if error_message then Error error_message else null
|
||||
callback error, ({id: source.id, name: source.name, thumbnail: NativeImage.createFromDataUrl source.thumbnail} for source in sources)
|
||||
|
||||
module.exports =
|
||||
getSources: getSources
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_LIST_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/time/time.h"
|
||||
#include "content/public/browser/desktop_media_id.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "base/hash.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
#include "chrome/browser/media/desktop_media_list_observer.h"
|
||||
|
|
Loading…
Reference in a new issue