mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Bug 587027 - Use as little memory as possible (part 1)
Move the Weave object out of service.js
This commit is contained in:
parent
cc929a11a8
commit
4f2fd07e21
74
services/sync/modules/main.js
Normal file
74
services/sync/modules/main.js
Normal file
@ -0,0 +1,74 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Sync
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Philipp von Weitershausen <philipp@weitershausen.de>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const EXPORTED_SYMBOLS = ['Weave'];
|
||||
|
||||
let Weave = {};
|
||||
Components.utils.import("resource://services-sync/constants.js", Weave);
|
||||
let lazies = {
|
||||
"auth.js": ['Auth', 'BrokenBasicAuthenticator',
|
||||
'BasicAuthenticator', 'NoOpAuthenticator'],
|
||||
"base_records/keys.js": ['PubKey', 'PrivKey', 'PubKeys', 'PrivKeys'],
|
||||
"engines.js": ['Engines', 'Engine', 'SyncEngine'],
|
||||
"engines/bookmarks.js": ['BookmarksEngine', 'BookmarksSharingManager'],
|
||||
"engines/clients.js": ["Clients"],
|
||||
"engines/forms.js": ["FormEngine"],
|
||||
"engines/history.js": ["HistoryEngine"],
|
||||
"engines/prefs.js": ["PrefsEngine"],
|
||||
"engines/passwords.js": ["PasswordEngine"],
|
||||
"engines/tabs.js": ["TabEngine"],
|
||||
"identity.js": ["Identity", "ID"],
|
||||
"notifications.js": ["Notifications", "Notification", "NotificationButton"],
|
||||
"resource.js": ["Resource"],
|
||||
"service.js": ["Service"],
|
||||
"status.js": ["Status"],
|
||||
"stores.js": ["Store"],
|
||||
"util.js": ['Utils', 'Svc', 'Str']
|
||||
};
|
||||
|
||||
function lazyImport(module, dest, props) {
|
||||
function getter(prop) function() {
|
||||
let ns = {};
|
||||
Components.utils.import(module, ns);
|
||||
delete dest[prop];
|
||||
return dest[prop] = ns[prop];
|
||||
};
|
||||
props.forEach(function(prop) dest.__defineGetter__(prop, getter(prop)));
|
||||
}
|
||||
|
||||
for (let mod in lazies) {
|
||||
lazyImport("resource://services-sync/" + mod, Weave, lazies[mod]);
|
||||
}
|
@ -36,7 +36,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const EXPORTED_SYMBOLS = ['Weave'];
|
||||
// 'Weave' continues to be exported for backwards compatibility.
|
||||
const EXPORTED_SYMBOLS = ["Service", "Weave"];
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
@ -58,34 +59,15 @@ Cu.import("resource://services-sync/constants.js");
|
||||
Cu.import("resource://services-sync/engines.js");
|
||||
Cu.import("resource://services-sync/engines/clients.js");
|
||||
Cu.import("resource://services-sync/ext/Sync.js");
|
||||
Cu.import("resource://services-sync/ext/Preferences.js");
|
||||
Cu.import("resource://services-sync/identity.js");
|
||||
Cu.import("resource://services-sync/log4moz.js");
|
||||
Cu.import("resource://services-sync/resource.js");
|
||||
Cu.import("resource://services-sync/status.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
Cu.import("resource://services-sync/main.js");
|
||||
|
||||
// for export
|
||||
let Weave = {};
|
||||
Cu.import("resource://services-sync/auth.js", Weave);
|
||||
Cu.import("resource://services-sync/constants.js", Weave);
|
||||
Cu.import("resource://services-sync/base_records/keys.js", Weave);
|
||||
Cu.import("resource://services-sync/engines.js", Weave);
|
||||
Cu.import("resource://services-sync/engines/bookmarks.js", Weave);
|
||||
Cu.import("resource://services-sync/engines/clients.js", Weave);
|
||||
Cu.import("resource://services-sync/engines/forms.js", Weave);
|
||||
Cu.import("resource://services-sync/engines/history.js", Weave);
|
||||
Cu.import("resource://services-sync/engines/prefs.js", Weave);
|
||||
Cu.import("resource://services-sync/engines/passwords.js", Weave);
|
||||
Cu.import("resource://services-sync/engines/tabs.js", Weave);
|
||||
Cu.import("resource://services-sync/ext/Preferences.js");
|
||||
Cu.import("resource://services-sync/identity.js", Weave);
|
||||
Cu.import("resource://services-sync/notifications.js", Weave);
|
||||
Cu.import("resource://services-sync/resource.js", Weave);
|
||||
Cu.import("resource://services-sync/status.js", Weave);
|
||||
Cu.import("resource://services-sync/stores.js", Weave);
|
||||
Cu.import("resource://services-sync/util.js", Weave);
|
||||
|
||||
Utils.lazy(Weave, 'Service', WeaveSvc);
|
||||
Utils.lazy(this, 'Service', WeaveSvc);
|
||||
|
||||
/*
|
||||
* Service singleton
|
||||
@ -875,7 +857,7 @@ WeaveSvc.prototype = {
|
||||
|
||||
let url = this.userAPI + username;
|
||||
let res = new Resource(url);
|
||||
res.authenticator = new Weave.NoOpAuthenticator();
|
||||
res.authenticator = new NoOpAuthenticator();
|
||||
|
||||
// Hint to server to allow scripted user creation or otherwise
|
||||
// ignore captcha.
|
||||
@ -1764,4 +1746,4 @@ WeaveSvc.prototype = {
|
||||
};
|
||||
|
||||
// Load Weave on the first time this file is loaded
|
||||
Weave.Service.onStartup();
|
||||
Service.onStartup();
|
||||
|
Loading…
Reference in New Issue
Block a user