Bug 121801 - Make WebHistory more type safe
Summary: Make WebHistory more type safe
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Patrick R. Gansterer
URL:
Keywords:
Depends on:
Blocks: 122010
  Show dependency treegraph
 
Reported: 2013-09-23 14:02 PDT by Patrick R. Gansterer
Modified: 2013-09-27 05:33 PDT (History)
2 users (show)

See Also:


Attachments
Patch (12.23 KB, patch)
2013-09-23 14:06 PDT, Patrick R. Gansterer
no flags Details | Formatted Diff | Diff
Patch (12.46 KB, patch)
2013-09-23 15:49 PDT, Patrick R. Gansterer
no flags Details | Formatted Diff | Diff
Patch (12.68 KB, patch)
2013-09-23 16:42 PDT, Patrick R. Gansterer
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick R. Gansterer 2013-09-23 14:02:55 PDT
Make WebHistory more type safe
Comment 1 Patrick R. Gansterer 2013-09-23 14:06:15 PDT
Created attachment 212387 [details]
Patch
Comment 2 Brent Fulgham 2013-09-23 15:30:23 PDT
Comment on attachment 212387 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=212387&action=review

I think the general idea of this change is good, but I don't agree with removing some of these methods, as they may be used by other WebKit clients.

> Source/WebKit/win/WebHistory.cpp:322
> +    DateToEntriesMap::iterator found = m_entriesByDate.find(dateKey(calendarDate));

How about 'auto found = ...'?

> Source/WebKit/win/WebHistory.cpp:343
> +        entriesForDate.at(i).copyRefTo(&items[i]);

Why use the "at(i)" syntax here? Is there some benefit over the square-bracket operator?

> Source/WebKit/win/WebHistory.h:-141
> -    HRESULT insertItem(IWebHistoryItem* entry, DateKey);

We don't want to get rid of the insertItem method.  I think "addItemToDateCaches" should be implemented in terms of insertItem.

> Source/WebKit/win/WebHistory.h:-143
> -    bool findKey(DateKey*, CFAbsoluteTime forDay);

Why don't we have 'bool findKey(DateKey*, DATE)'?  Why don't we want to keep this?
Comment 3 Patrick R. Gansterer 2013-09-23 15:39:28 PDT
Comment on attachment 212387 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=212387&action=review

>> Source/WebKit/win/WebHistory.cpp:322
>> +    DateToEntriesMap::iterator found = m_entriesByDate.find(dateKey(calendarDate));
> 
> How about 'auto found = ...'?

i copy&pasted it from other places, but i'm ok with the auto here too

>> Source/WebKit/win/WebHistory.cpp:343
>> +        entriesForDate.at(i).copyRefTo(&items[i]);
> 
> Why use the "at(i)" syntax here? Is there some benefit over the square-bracket operator?

no, i'll fix it

>> Source/WebKit/win/WebHistory.h:-141
>> -    HRESULT insertItem(IWebHistoryItem* entry, DateKey);
> 
> We don't want to get rid of the insertItem method.  I think "addItemToDateCaches" should be implemented in terms of insertItem.

it's private, so there should be nobody able to use it

>> Source/WebKit/win/WebHistory.h:-143
>> -    bool findKey(DateKey*, CFAbsoluteTime forDay);
> 
> Why don't we have 'bool findKey(DateKey*, DATE)'?  Why don't we want to keep this?

because we use the iterator now everywhere -> not needed
Comment 4 Brent Fulgham 2013-09-23 15:40:46 PDT
Comment on attachment 212387 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=212387&action=review

>>> Source/WebKit/win/WebHistory.h:-141
>>> -    HRESULT insertItem(IWebHistoryItem* entry, DateKey);
>> 
>> We don't want to get rid of the insertItem method.  I think "addItemToDateCaches" should be implemented in terms of insertItem.
> 
> it's private, so there should be nobody able to use it

Ah -- I missed that.  Okay -- never mind.

>>> Source/WebKit/win/WebHistory.h:-143
>>> -    bool findKey(DateKey*, CFAbsoluteTime forDay);
>> 
>> Why don't we have 'bool findKey(DateKey*, DATE)'?  Why don't we want to keep this?
> 
> because we use the iterator now everywhere -> not needed

Seems fine then.
Comment 5 Patrick R. Gansterer 2013-09-23 15:49:28 PDT
Created attachment 212401 [details]
Patch
Comment 6 Brent Fulgham 2013-09-23 16:24:45 PDT
Comment on attachment 212401 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=212401&action=review

Looks good.  I did notice a couple of minor things that I missed last time.  The only one I really care about is the naming of the last visited time (I think this should stay as "lastVisitedTime", not be written as "entryTime".

You can fix this while landing, or you can upload a final patch and I will r+ that.

> Source/WebKit/win/WebHistory.cpp:590
> +    DATE entryTime;

I just noticed that this should be "lastVisitedTime".

> Source/WebKit/win/WebHistory.cpp:595
>          return E_FAIL;

This isn't your doing, but I wonder if attempting to remove an entry that is already not in the entry queue should be considered failure.  Seems like a safe "success" case to me.

> Source/WebKit/win/WebHistory.cpp:601
> +        if (entriesForDate.at(i) == entry)

We don't tend to use the "at()" method, but this is okay.

> Source/WebKit/win/WebHistory.cpp:625
> +        Vector<COMPtr<IWebHistoryItem> > entries(1);

You don't need the space here "> >" can be ">>" under C++11. :-)

> Source/WebKit/win/WebHistory.cpp:664
> +        if (FAILED(entriesForDate.at(mid)->lastVisitedTimeInterval(&itemTime)))

... another "at()".

> Source/WebKit/win/WebHistory.h:120
> +    typedef HashMap<DateKey, Vector<COMPtr<IWebHistoryItem> > > DateToEntriesMap;

You can write this as "...IWebHistoryItem>>>"
Comment 7 Patrick R. Gansterer 2013-09-23 16:42:19 PDT
Created attachment 212405 [details]
Patch
Comment 8 Brent Fulgham 2013-09-23 16:47:48 PDT
Comment on attachment 212405 [details]
Patch

r=me
Comment 9 WebKit Commit Bot 2013-09-24 00:32:26 PDT
Comment on attachment 212405 [details]
Patch

Clearing flags on attachment: 212405

Committed r156321: <http://trac.webkit.org/changeset/156321>
Comment 10 WebKit Commit Bot 2013-09-24 00:32:28 PDT
All reviewed patches have been landed.  Closing bug.