<commit_before>var BackEndMessaging = (function () {


    function sendMessage(message, onResponse) {
        var msg = MessagePassing.PrepareMessage(message);
        chrome.runtime.sendMessage(msg, onResponse);
    }

    function shouldProcess(message) {
        return message.to == MessagePassing.Destinations.BACK;
    }

    return {

        handleMessage: function (rawMessage, sender, sendResponse) {

            debug("BackEndMessaging handleMessage");

            // make sure we should process this message
            if (!shouldProcess(rawMessage)) {
                debug("We should not process this message:", rawMessage);
                return;
            }

            debug("We should process this message:", rawMessage);

            var message = MessagePassing.ParseMessage(rawMessage);

            /** @var message MessagePassing */
            switch (message.type) {
                case MessagePassing.MessageTypes.NEW_DATA_CREATED:
                    debug("Received a message of type NEW_DATA_CREATED: ", message);

                    var appController = ApplicationController.getInstance();
                    appController.newDataCreated(message.content);

                    break;
                case MessagePassing.MessageTypes.OPENED_WINDOW:
                    var appController = ApplicationController.getInstance();
                    appController.appStarted();
                    break;
                case MessagePassing.MessageTypes.CLOSING_WINDOW:
                    debug("Received a message of type CLOSING_WINDOW", message);

                    var appController = ApplicationController.getInstance();
                    appController.appClosed();
                    break;
                case MessagePassing.MessageTypes.PRINT_PEER_LIST:
                    debug("Received a message to print the peer list");
                    var c = Context.getInstance();
                    c.printPeerList();
                    break;
                case MessagePassing.MessageTypes.PERFORM_DIRECT_REPLICATION_REQUEST:
                    debug("Received a message to perform direct replication");
                    var c = Context.getInstance();
                    var peers = c.getAllPeers();
                    if (peers.length > 0) {
                        log("Sending direct replication request to peer ["+peers[0].getReplicaIdentityString()+"] at "+ peers[0].getIpAddress());
                        ReplicationController.SendDirectReplicationRequest(peers[0]);
                    } else {
                        log("NOT Sending direct replication request because we don't have enough peers.");
                    }
                    break;
                default:
                    debug("Received message that should not handle [" + message.type + "]: ", message);
            }

        },

        sendMessage: function (message, onResponse) {
            return sendMessage(message, onResponse);
        }

    };
})();<commit_msg>Adding support for new_cell_value message type. The frontend can now set new values to the cells :)<commit_after>var BackEndMessaging = (function () {


    function sendMessage(message, onResponse) {
        var msg = MessagePassing.PrepareMessage(message);
        chrome.runtime.sendMessage(msg, onResponse);
    }

    function shouldProcess(message) {
        return message.to == MessagePassing.Destinations.BACK;
    }

    return {

        handleMessage: function (rawMessage, sender, sendResponse) {

            debug("BackEndMessaging handleMessage");

            // make sure we should process this message
            if (!shouldProcess(rawMessage)) {
                debug("We should not process this message:", rawMessage);
                return;
            }

            debug("We should process this message:", rawMessage);

            var message = MessagePassing.ParseMessage(rawMessage);

            /** @var message MessagePassing */
            switch (message.type) {
                case MessagePassing.MessageTypes.NEW_DATA_CREATED:
                    debug("Received a message of type NEW_DATA_CREATED: ", message);

                    var appController = ApplicationController.getInstance();
                    appController.newDataCreated(message.content);

                    break;
                case MessagePassing.MessageTypes.OPENED_WINDOW:
                    var appController = ApplicationController.getInstance();
                    appController.appStarted();
                    break;
                case MessagePassing.MessageTypes.CLOSING_WINDOW:
                    debug("Received a message of type CLOSING_WINDOW", message);

                    var appController = ApplicationController.getInstance();
                    appController.appClosed();
                    break;
                case MessagePassing.MessageTypes.PRINT_PEER_LIST:
                    debug("Received a message to print the peer list");
                    var c = Context.getInstance();
                    c.printPeerList();
                    break;
                case MessagePassing.MessageTypes.PERFORM_DIRECT_REPLICATION_REQUEST:
                    debug("Received a message to perform direct replication");
                    var c = Context.getInstance();
                    var peers = c.getAllPeers();
                    if (peers.length > 0) {
                        log("Sending direct replication request to peer ["+peers[0].getReplicaIdentityString()+"] at "+ peers[0].getIpAddress());
                        ReplicationController.SendDirectReplicationRequest(peers[0]);
                    } else {
                        log("NOT Sending direct replication request because we don't have enough peers.");
                    }
                    break;
                case MessagePassing.MessageTypes.NEW_CELL_VALUE:
                        debug("Received a message with a new cell value");
                        var appController = ApplicationController.getInstance();
                        var content = message.content;
                        appController.updatedCellValue(content.row, content.col, content.value);
                    break;
                default:
                    debug("Received message that should not handle [" + message.type + "]: ", message);
            }

        },

        sendMessage: function (message, onResponse) {
            return sendMessage(message, onResponse);
        }

    };
})();
{'fraction_non_alphanumeric': 0.08205521472392638, 'fraction_numerical': 0.001226993865030675, 'mean_word_length': 1.6990894039735098, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '513142', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1369, 'n_words': 360}