From 0645da4efce96be5cf4b1d1e6a808b07bb8e2f07 Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Mon, 2 Sep 2013 21:27:24 +0300 Subject: [PATCH] Rearranged to be more structured. --- CefSharp.BrowserSubprocess/CefRenderProcess.h | 12 ++++++ .../CefSharp.BrowserSubprocess.vcxproj | 2 + ...CefSharp.BrowserSubprocess.vcxproj.filters | 6 +++ CefSharp.BrowserSubprocess/JavascriptProxy.h | 2 +- .../JavascriptProxyService.h | 36 ++++++++++++++++++ CefSharp.BrowserSubprocess/Program.cpp | 37 +++---------------- 6 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 CefSharp.BrowserSubprocess/CefRenderProcess.h create mode 100644 CefSharp.BrowserSubprocess/JavascriptProxyService.h diff --git a/CefSharp.BrowserSubprocess/CefRenderProcess.h b/CefSharp.BrowserSubprocess/CefRenderProcess.h new file mode 100644 index 000000000..28f906243 --- /dev/null +++ b/CefSharp.BrowserSubprocess/CefRenderProcess.h @@ -0,0 +1,12 @@ +// Copyright © 2013 The CefSharp Project. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +#include "include/cef_app.h" + +int ExecuteCefRenderProcess(HINSTANCE hInstance) +{ + CefMainArgs main_args(hInstance); + CefRefPtr app; + return CefExecuteProcess(main_args, app); +} diff --git a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj index d5a9daf2a..5f80b73f3 100644 --- a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj +++ b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj @@ -102,7 +102,9 @@ + + diff --git a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj.filters b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj.filters index be44566c7..854b5bb01 100644 --- a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj.filters +++ b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.vcxproj.filters @@ -18,6 +18,12 @@ Header Files + + Header Files + + + Header Files + diff --git a/CefSharp.BrowserSubprocess/JavascriptProxy.h b/CefSharp.BrowserSubprocess/JavascriptProxy.h index d8e4249f4..644c55839 100644 --- a/CefSharp.BrowserSubprocess/JavascriptProxy.h +++ b/CefSharp.BrowserSubprocess/JavascriptProxy.h @@ -1,4 +1,4 @@ -// Copyright © 2010-2013 The CefSharp Project. All rights reserved. +// Copyright © 2013 The CefSharp Project. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/CefSharp.BrowserSubprocess/JavascriptProxyService.h b/CefSharp.BrowserSubprocess/JavascriptProxyService.h new file mode 100644 index 000000000..c7e7748d8 --- /dev/null +++ b/CefSharp.BrowserSubprocess/JavascriptProxyService.h @@ -0,0 +1,36 @@ +// Copyright © 2013 The CefSharp Project. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +#pragma once + +#include "JavascriptProxy.h" + +using namespace CefSharp::Internals::JavascriptBinding; +using namespace CefSharp::BrowserSubprocess; +using namespace System; +using namespace System::ServiceModel; +using namespace System::Threading; + +static void ThreadEntryPoint(); + +void CreateJavascriptProxyServiceHost() +{ + auto thread = gcnew Thread(gcnew ThreadStart(ThreadEntryPoint)); + thread->Start(); +} + +void ThreadEntryPoint() +{ + auto uris = gcnew array(1); + uris[0] = gcnew Uri(JavascriptProxy::BaseAddress); + + auto host = gcnew ServiceHost(JavascriptProxy::typeid, uris); + host->AddServiceEndpoint( + IJavascriptProxy::typeid, + gcnew NetNamedPipeBinding(), + JavascriptProxy::ServiceName + ); + + host->Open(); +} diff --git a/CefSharp.BrowserSubprocess/Program.cpp b/CefSharp.BrowserSubprocess/Program.cpp index 0fcdff3a4..dbfb42a6b 100644 --- a/CefSharp.BrowserSubprocess/Program.cpp +++ b/CefSharp.BrowserSubprocess/Program.cpp @@ -1,39 +1,12 @@ -// Copyright © 2010-2013 The CefSharp Project. All rights reserved. +// Copyright © 2013 The CefSharp Project. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. -#include "include/cef_app.h" -#include "JavascriptProxy.h" - -using namespace CefSharp::Internals::JavascriptBinding; -using namespace CefSharp::BrowserSubprocess; -using namespace System; -using namespace System::ServiceModel; -using namespace System::Threading; - -static void threadEntryPoint(); +#include "CefRenderProcess.h" +#include "JavascriptProxyService.h" int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { - auto thread = gcnew Thread(gcnew ThreadStart(threadEntryPoint)); - thread->Start(); - - CefMainArgs main_args(hInstance); - CefRefPtr app; - return CefExecuteProcess(main_args, app); -} - -void threadEntryPoint() -{ - auto uris = gcnew array(1); - uris[0] = gcnew Uri(JavascriptProxy::BaseAddress); - - auto host = gcnew ServiceHost(JavascriptProxy::typeid, uris); - host->AddServiceEndpoint( - IJavascriptProxy::typeid, - gcnew NetNamedPipeBinding(), - JavascriptProxy::ServiceName - ); - - host->Open(); + CreateJavascriptProxyServiceHost(); + return ExecuteCefRenderProcess(hInstance); }