1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_MONITOR_FINDER_MAC_H_
6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_MONITOR_FINDER_MAC_H_
8 #include <ApplicationServices/ApplicationServices.h>
10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h"
15 // MonitorFinder maps a RenderFrameHost to the display ID on which the widget
16 // is painting. This class operates on the IO thread while the RenderFrameHost
17 // is on the UI thread, so the value returned by GetMonitor() may be 0 until
18 // the information can be retrieved asynchronously.
19 class MonitorFinder
: public base::RefCountedThreadSafe
<MonitorFinder
> {
21 MonitorFinder(int process_id
, int render_frame_id
);
23 // Gets the native display ID for the <process_id, render_frame_id> tuple.
26 // Checks if the given |monitor_id| represents a built-in display.
27 static bool IsMonitorBuiltIn(int64_t monitor_id
);
30 friend class base::RefCountedThreadSafe
<MonitorFinder
>;
33 // Method run on the UI thread to get the display information.
34 void FetchMonitorFromWidget();
36 const int process_id_
;
37 const int render_frame_id_
;
39 base::Lock mutex_
; // Protects the two members below.
40 // Whether one request to FetchMonitorFromWidget() has been made already.
42 // The native display ID for the RenderFrameHost.
43 CGDirectDisplayID display_id_
;
45 DISALLOW_COPY_AND_ASSIGN(MonitorFinder
);
50 #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_MONITOR_FINDER_H_