• huangs@chromium.org's avatar
    Implementing URL prefix match for history thumbnail cache. · 420e6d9e
    huangs@chromium.org authored
    We wish to make MostLikely URL recommendations use local thumbnail. To increase the likelihood of a hit, this CL enables a thumbnail request to perform URL prefix match. For example, if thumbnail is stored for
    ==> http://www.chromium.org/Home
    but not
    ==>  http://www.chromium.org/
    then previously the request
    ==>  chrome://thumb/http://www.chromium.org/
    would fail. This CL aims to create a fallback, by adding "thumb2" that matches prefix, i.e.:
    ==>  chrome://thumb2/http://www.chromium.org/
    would match "http://www.chromium.org/Home" and display the corresponding thumbnail. Details:
    
    - We consider "URL prefix" match, which is not same as "string prefix" match. Specifics:
    --- Need identical protocol/scheme, host, and port (GURL is smart about this).
    --- Query strings are ignored.
    --- For path, we require entire path components to match. E.g., "base/test" is a prefix of "base/test/sub", but is NOT a prefix of "base/testing" or "best/test-case".
    
    - If multiple matches exist, the first URL-lexicographical match is taken. This allows the "nearest" children to be matched, but favors siblings that are alphabetically closer. For example, "base" prefers "base/test" over "base/test/sub", but also prefers "base/deep/sub/dir/" over "base/test" (since "deep" < "test").
    
    - To implement the above match, a new comparator is used in the thumbnail cache.
    
    - Adding new test TopSitesCacheTest, which also tests existing code.
    
    - Adding url_utils.cc in chrome\browser\history, along with unit tests.
    
    - Adding the "chrome://thumb2" path, which causes most of the 1-2-line changes in files.
    
    BUG=284634
    TEST=TopSitesCacheTest.*
    
    Review URL: https://chromiumcodereview.appspot.com/23477033
    
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223508 0039d316-1c4b-4281-b951-d872f2087c98
    420e6d9e
url_utils_unittest.cc 3.71 KB