• dominickn's avatar
    Refactor WebappRegistry into a singleton instance. · 78cf6596
    dominickn authored
    This CL refactors WebappRegistry and WebappDataStorage to make most of
    the methods synchronous. WebappRegistry is now a singleton instance that
    is instantiated at browser startup. This allows all SharedPreferences files to
    be pre-warmed before the class is used; new web apps open new
    SharedPreferences on a background thread when registered, after which the
    preferences are cached automatically.
    
    Most static methods on WebappRegistry and WebappDataStorage have been
    converted to instance methods or removed. This makes the code much
    cleaner and more efficient; each static method had to independently open
    their SharedPreferences, which minimally performs a stat() on the
    underlying XML file to see if it has changed. Now the singleton
    WebappRegistry caches all WebappDataStorage objects on startup and
    whenever new ones are added. This reduces disk IO overhead.
    
    This CL allows all calls to SharedPreferences.Editor.apply() in
    WebappRegistry and WebappDataStorage to occur on the main thread,
    mostly removing the need for unwieldy callback interfaces and bare
    pointer passing across the JNI.
    
    BUG=633791
    
    Review-Url: https://codereview.chromium.org/2351113005
    Cr-Commit-Position: refs/heads/master@{#422703}
    78cf6596
chrome_jni_registrar.cc 23.2 KB