Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

[Linux only] Upgrading to CEF 2704 #619

Merged
merged 22 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
module.exports = function (grunt) {
var common = require("./tasks/common")(grunt),
platform = common.platform(),
staging;
staging,
cef_version = "3.2623.1397";

if (platform === "mac") {
staging = "installer/mac/staging/<%= build.name %>.app/Contents";
Expand All @@ -36,6 +37,10 @@ module.exports = function (grunt) {
staging = "installer/linux/debian/package-root/opt/brackets";
}

if (platform === "linux") {
cef_version = "3.2704.1414";
}

grunt.initConfig({
"pkg": grunt.file.readJSON("package.json"),
"config-json": staging + "/www/config.json",
Expand All @@ -58,6 +63,14 @@ module.exports = function (grunt) {
"dest" : "<%= downloads %>",
"src" : "http://nodejs.org/dist/v<%= node.version %>/node-v<%= node.version %>-linux-x64.tar.gz"
},
"icu-linux32": {
"dest" : "<%= downloads %>",
"src" : "<%= icu.url %>/icu_<%= icu.version %>_linux32_release.zip"
},
"icu-linux64": {
"dest" : "<%= downloads %>",
"src" : "<%= icu.url %>/icu_<%= icu.version %>_linux64_release.zip"
},
/* mac */
"cef-mac": {
"dest" : "<%= downloads %>",
Expand Down Expand Up @@ -171,7 +184,12 @@ module.exports = function (grunt) {
"cef_100_percent.pak",
"cef_200_percent.pak",
"devtools_resources.pak",
"cef_extensions.pak",
"icudtl.dat",
"libcef.so",
"natives_blob.bin",
"snapshot_blob.bin",
"chrome-sandbox",
],
"dest" : "<%= build.staging %>"
},
Expand Down Expand Up @@ -245,7 +263,7 @@ module.exports = function (grunt) {
},
"cef": {
"url" : "http://s3.amazonaws.com/files.brackets.io/cef",
"version" : "3.2623.1397"
"version" : cef_version
},
"node": {
"version" : "6.3.1"
Expand Down
6 changes: 6 additions & 0 deletions appshell.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,19 @@
],
'link_settings': {
'ldflags': [
'-pthread',
'-Wl,-rpath,\$$ORIGIN/',
'<(march)'
],
'libraries': [
"$(BUILDTYPE)/libcef.so",
"-lX11",
'appshell_extensions_js.o',
'deps/icu/lib/libicuuc.a',
'deps/icu/lib/libicuio.a',
'deps/icu/lib/libicui18n.a',
'deps/icu/lib/libicudata.a',
'-ldl',
],
},
'sources': [
Expand Down
77 changes: 70 additions & 7 deletions appshell/appshell_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
#include "appshell_node_process.h"
#include "config.h"

#ifdef OS_LINUX
#include "appshell/browser/main_context.h"
#include "appshell/browser/root_window_manager.h"
#endif

#include <algorithm>

extern std::vector<CefString> gDroppedFiles;
Expand Down Expand Up @@ -394,10 +399,15 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
CefWindowInfo wi;
CefBrowserSettings settings;

#if defined(OS_WIN)
wi.SetAsPopup(NULL, "DevTools");
#endif
browser->GetHost()->ShowDevTools(wi, browser->GetHost()->GetClient(), settings, CefPoint());
#if defined(OS_WIN)
wi.SetAsPopup(NULL, "DevTools");
#elif defined(OS_LINUX)
handler->ShowDevTools(browser, CefPoint());
#endif

#ifndef OS_LINUX
browser->GetHost()->ShowDevTools(wi, browser->GetHost()->GetClient(), settings, CefPoint());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement seems to be executed in case of MAC, so can we have a separate #elif case in line 406 only.
Something like #ifdef OS_MAC, it would make it more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement needs to be executed for MAC as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will see if I can simplify this for better readability.

#endif

} else if (message_name == "GetNodeState") {
// Parameters:
Expand All @@ -423,7 +433,15 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {

// The DispatchCloseToNextBrowser() call initiates a quit sequence. The app will
// quit if all browser windows are closed.
handler->DispatchCloseToNextBrowser();
#ifdef OS_LINUX
if(client::MainContext::Get() &&
client::MainContext::Get()->GetRootWindowManager()){
client::MainContext::Get()->GetRootWindowManager()->DispatchCloseToNextWindow();
}
#else
handler->DispatchCloseToNextBrowser();
#endif


} else if (message_name == "AbortQuit") {
// Parameters - none
Expand Down Expand Up @@ -765,8 +783,53 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
// 0: int32 - callback id

responseArgs->SetString(2, GetSystemUniqueID());
}
else {
}
else if (message_name == "ReadDirWithStats") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please highlight the place where this message is called.

Copy link
Contributor Author

@nethip nethip Aug 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here is the thing. In my testing what I figured out was readDir leads to lot of shell calls. Here is what happens for readDir. First we get plain contents of a directory and for every file entry, we then make a stat call to shell. With our Brackets repository open, this led to close to 33,000 shell calls. So if all we want is to get directory contents and file stats we could very well do that in a single shell call. Using this has reduced the no of shell calls to 5000 for readDir, for Brackets repo. So I guess this should pretty much be made mainstream. For now, I have just kept it added and in another PR, I would replace "ReadDir" shell call with "ReadDirWithStats". Does it make sense to remove this here and raise another PR for this?

// Parameters:
// 0: int32 - callback id

CefRefPtr<CefListValue> uberDict = CefListValue::Create();
CefRefPtr<CefListValue> dirContents = CefListValue::Create();
CefRefPtr<CefListValue> allStats = CefListValue::Create();

ExtensionString path = argList->GetString(1);
ReadDir(path, dirContents);

// Now we iterator through the contents of directoryContents.
size_t theSize = dirContents->GetSize();
for ( size_t iFileEntry = 0; iFileEntry < theSize ; ++iFileEntry) {
CefRefPtr<CefListValue> fileStats = CefListValue::Create();

#ifdef OS_WIN
ExtensionString theFile = path + L"/";
#else
ExtensionString theFile = path + "/";
#endif

ExtensionString fileName = dirContents->GetString(iFileEntry);
theFile = theFile + fileName;

ExtensionString realPath;
uint32 modtime;
double size;
bool isDir;
GetFileInfo(theFile, modtime, isDir, size, realPath);

fileStats->SetInt(0, modtime);
fileStats->SetBool(1, isDir);
fileStats->SetInt(2, size);
fileStats->SetString(3, realPath);

allStats->SetList(iFileEntry, fileStats);

}

uberDict->SetList(0, dirContents);
uberDict->SetList(1, allStats);
responseArgs->SetList(2, uberDict);
}

else {
fprintf(stderr, "Native function not implemented yet: %s\n", message_name.c_str());
return false;
}
Expand Down
46 changes: 44 additions & 2 deletions appshell/appshell_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,50 @@ if (!appshell.app) {
}, path);
};



/**
* Reads the contents of a directory and reports contents along with stats.
*
* @param {string} path The path of the directory to read.
* @param {function(err, files)} callback Asynchronous callback function. The callback gets three arguments
* (err, files, stats) where files is an array of the names of the files
* in the directory excluding '.' and '..' and stats is an array of all stats of the files.
* Possible error values:
* NO_ERROR
* ERR_UNKNOWN
* ERR_INVALID_PARAMS
* ERR_NOT_FOUND
* ERR_CANT_READ
*
* @return None. This is an asynchronous call that sends all return information to the callback.
*/
// Test dictionary
native function ReadDirWithStats();
appshell.fs.readDirWithStats = function (path, callback){

ReadDirWithStats(function (err, allPaths){
if (callback) {
var finalArray = [];
var allContents = allPaths[0];
var allStats = allPaths[1];

allStats.forEach(function (val, idx) {
finalArray[idx] = {
isFile: function () {
return !val[1];
},
isDirectory: function () {
return val[1];
},
mtime: new Date(val[0] * 1000), // modtime is seconds since 1970, convert to ms
size: new Number(val[2]),
realPath: val[3] ? val[3] : null
}
});
callback(err, allContents, finalArray);
}
}, path);
};

/**
* Quits native shell application
*/
Expand Down
Loading